Need help to write a backup script...

Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jul 2009
Posts: 7
Reputation: baula is an unknown quantity at this point 
Solved Threads: 0
baula baula is offline Offline
Newbie Poster

Need help to write a backup script...

 
0
  #1
Aug 21st, 2009
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...

Example:
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 ( [i]ncremental / [f]ull backup) [i]:
Follow symbolic link (Y/N) [n]:
Directory backed up successfully...

Plz help me to do this... ...

Thnx
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,224
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 574
Sponsor
sknake's Avatar
sknake sknake is online now Online
.NET Enthusiast

Re: Need help to write a backup script...

 
0
  #2
Aug 21st, 2009
Use rsync. It already does this and has more robust command line options.
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 7
Reputation: baula is an unknown quantity at this point 
Solved Threads: 0
baula baula is offline Offline
Newbie Poster

Re: Need help to write a backup script...

 
0
  #3
Aug 21st, 2009
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...
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,224
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 574
Sponsor
sknake's Avatar
sknake sknake is online now Online
.NET Enthusiast

Re: Need help to write a backup script...

 
0
  #4
Aug 21st, 2009
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...
Last edited by sknake; Aug 21st, 2009 at 4:45 pm.
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 7
Reputation: baula is an unknown quantity at this point 
Solved Threads: 0
baula baula is offline Offline
Newbie Poster

Re: Need help to write a backup script...

 
0
  #5
Aug 21st, 2009
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...

Thnx
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,224
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 574
Sponsor
sknake's Avatar
sknake sknake is online now Online
.NET Enthusiast

Re: Need help to write a backup script...

 
0
  #6
Aug 21st, 2009
I'll get you started with the user input. Here is the sample output:
  1. sk@sk:~/tmp$ ./ba.sh
  2. syntax: ./ba.sh [ -i/ -f file]
  3. sk@sk:~/tmp$ ./ba.sh -i
  4. Welcome to the Interactive Backup utility
  5. Enter the source directory [/home/maskara/sya710]: /ab
  6. Enter the destination directory [/home/backup]: /dc
  7. /ab
  8. /dc

Now the actual script:
  1. #!/bin/bash
  2.  
  3. d_srcdir="/home/maskara/sya710"
  4. d_dstdir="/home/backup"
  5.  
  6. if ([ "$1" == "-i" ]); then
  7. echo "Welcome to the Interactive Backup utility"
  8. echo -n "Enter the source directory [${d_srcdir}]: "
  9. read srcdir
  10.  
  11. if ! test $srcdir; then
  12. srcdir=${d_srcdir}
  13. fi
  14.  
  15. echo -n "Enter the destination directory [${d_dstdir}]: "
  16. read dstdir
  17.  
  18. if ! test $dstdir; then
  19. dstdir=${d_dstdir}
  20. fi
  21.  
  22. echo ${srcdir}
  23. echo ${dstdir}
  24.  
  25. else
  26. echo "syntax: ${0} [ -i/ -f file]"
  27. fi
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 7
Reputation: baula is an unknown quantity at this point 
Solved Threads: 0
baula baula is offline Offline
Newbie Poster

Re: Need help to write a backup script...

 
0
  #7
Sep 3rd, 2009
Dear sknake,

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

Thnx again...
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC