LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-04-2014, 07:59 AM   #16
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694

First off -- edit that post and put the code in CODE brackets.
 
Old 03-05-2014, 11:44 AM   #17
diw10
LQ Newbie
 
Registered: Feb 2014
Posts: 13

Original Poster
Rep: Reputation: Disabled
Code:
#!/bin/ksh
#
#SCRIPT: backupk script


#####################################
# PATH Declaration
MOUNT=/bin/mount
UMOUNT=/bin/umount
#####################################


#####################################
#Function Declaration

#Function for taking Local Backup
GetPathLocal ( ) { echo "Enter the Destination Directory[ ]:"
echo "No Default,Enter absolute path"
read DEST_PATH
  CreateArch
}

#Function for taking Remote Backup
GetPathRemote ( ) { echo "\nEnter the Remote Machine IP Address[No Default]:\c "
read DEST_IP

echo "\nEnter the Remote Directory to be mounted[no default ]:\c"

read REMOTE_DIR

ISMOUNTED=`$MOUNT | grep "/mntback"`
if [ "$ISMOUNTED" = "" ]
then
  if [ -d /mntback ]
  then 
  echo `$MOUNT $DEST_IP:$REMOTE_DIR /mntback`
  else
  mkdir /mntback
  echo `$MOUNT $DEST_IP:$REMOTE_DIR /mntback`
  fi
fi

echo "\nEnter the Destination Directory Name[No default]:\c"
read DEST_NAME
DEST_PATH=/mntback/$DEST_NAME

CreateArch
$UMOUNT /mntback

}

#Function Performing Backup
CreateArch ( ) { if [ -d $SOUR_PATH ]
    then
    if [ ! -d $DEST_PATH ]
    then
     echo "Destination Directory does not exist.Creating..."
     mkdir $DEST_PATH
    fi 
    ls -1F $SOUR_PATH | grep / |awk -F/ '{print $1}' - > /tmp/user
  
    cd $SOUR_PATH
   
    for i in `cat /tmp/user`
  do
  #tar  cvfp - $i | gzip > $DEST_PATH/$i.tar.gz
  tar cvfpBz  $DEST_PATH/$i.tar.gz  $i  # taking tar & zipping
done
    GenerateReadme

    else
echo "\nError: Source not a directory
EXITING BACKUP"
exit 1
    fi



rm /tmp/user

}
#Function to Generate Readme file after backup is completed
GenerateReadme ( ) { README=$DEST_PATH/readme
echo "
***************************************************
               BACKUP  README    
***************************************************

        1. FileSystem Name(Source):     $SOUR_PATH    
        2. Date of Creation:            `date`
        3. Machine used for backup:     `hostname`   
        4. Destination(IP Address):     $DEST_IP     
        5. Destination(Path):           $REMOTE_DIR/$DEST_NAME " >$README

}

######################################
#######  BEGINNING OF MAIN ###########
######################################

echo  "\
**********************************************************
*                                                        *
*                        BACKUP UTILITY           *
*                                                        *
**********************************************************
  \n
Enter \"e\" to EXIT or \"c\" to CONTINUE [no default]: \c"
read ANSW

case $ANSW in
   c|C)
   echo "\nEnter the source Directory(Full Path)[ ]: \c"
        
         read SOUR_PATH

   echo "\nDestination  Kind:\n
          Local  [1]
          Remote [2]
         
Enter your choice [no default]: \c"
         
        read DEST_KIND
        
         case $DEST_KIND in
         1)
         GetPathLocal
         ;;
         2)
         GetPathRemote
         ;;
         *)
         echo "\n
     No other option
***** BACKUP Exit *****"
         exit 0
         ;;
        esac
    ;;   
   e|E)
    exit 0
    ;;
   *)
    echo "\n
No other option
***** BACKUP Exit *****"
    exit 0
    ;;
esac

Last edited by diw10; 03-05-2014 at 11:49 AM.
 
Old 03-05-2014, 11:50 AM   #18
diw10
LQ Newbie
 
Registered: Feb 2014
Posts: 13

Original Poster
Rep: Reputation: Disabled
guys please help......
 
Old 03-06-2014, 08:08 AM   #19
diw10
LQ Newbie
 
Registered: Feb 2014
Posts: 13

Original Poster
Rep: Reputation: Disabled
guys please help....
 
Old 03-06-2014, 08:16 AM   #20
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
if you want to remove the echos so it doesnt prompt for user input, then the obvious solution would be to remove each echo and read and hard code those values in the script (or better yet: take them in as command-line parameters).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
backup script help tsitras Linux - General 2 02-20-2013 09:38 AM
What happens with backup-manager.org (very useful backup script)? Murz Linux - Software 3 07-27-2010 06:46 AM
Newbie trying to write a simple backup script to backup a single folder Nd for school stryker759a Linux - Newbie 2 09-16-2009 08:52 AM
Need help with script to organise files into folders as part of DVD backup script jasybee2000 Linux - Newbie 5 06-15-2009 07:29 PM
how to create backup MYSQL Script to backup my database for every 1hour RMLinux Linux - Newbie 3 11-20-2008 10:13 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration