Helo frndz,
I'm novice in shell scripting...I need ur frnd help to write a shell script for taking backups. This script should use cp command to take backups. Script can read the list of directories and destination directory from a file or ask user for this info interactively...

Only two options -i (for interactive run) and "-f file" (to read backup info from a file) are allowed. When an invalid option is entered, script displays a message in shown below:
$ a2backup -r
syntax: a2backup [ -i/ -f file]

$ a2backup -i
Welcome to the Interactive Backup utility
Enter the source directory [/home/maskara/sya710]:
Enter the destination directory: /home/backup
What type of backup do you want ( ncremental / [f]ull backup) :
Follow symbolic link (Y/N) [n]:
Directory backed up successfully...

Plz help me to do this...:( ...


Sory dear SKnake, Thnx for ur reply...But I cant use any software...:( it's my assignment, have to do with writing a script...:( & also have to follow da above mentioned example...:( ...any other advise?? Do U know how to write this code?? plz help me...

Thnx again...

Why don't you share the code you have so far so we can see what needs to be done? The incremental backup is going to be a little bit of work...

Dear sknake,
I dun have code yet...I dun understand where I've to start!...:( I'm still trying to write this code...I dun understand how to initialize da OPTION value, so that da entered value (i.e, except '-i' or '-f') is invalid or not...I'm not good in programming man...:(


I'll get you started with the user input. Here is the sample output:

sk@sk:~/tmp$ ./ba.sh
syntax: ./ba.sh [ -i/ -f file]
sk@sk:~/tmp$ ./ba.sh -i
Welcome to the Interactive Backup utility
Enter the source directory [/home/maskara/sya710]: /ab
Enter the destination directory [/home/backup]: /dc

Now the actual script:



if ([ "$1" == "-i" ]); then
  echo "Welcome to the Interactive Backup utility"
  echo -n "Enter the source directory [${d_srcdir}]: "
  read srcdir

  if ! test $srcdir; then

  echo -n "Enter the destination directory [${d_dstdir}]: "
  read dstdir

  if ! test $dstdir; then

  echo ${srcdir}
  echo ${dstdir}

  echo "syntax: ${0} [ -i/ -f file]"

Dear sknake,

Sorry for long late reply...Thank you very much...It was really very helpful!...:D

Thnx again...

This question has already been answered. Start a new discussion instead.