Creating a back up shell script
hi guys,
i need a backup script that has some options in it for my family to use and i need some help with the coding. The script needs to do the following for us: 1.The utility will ask the user which directory to backup 2.The utility will ask for the fullpathname of the backup file to create. Also I need the utility to ask any user if they would require another backup? if no the user can enter a n=no. If no comment the backup utility will loop back and repeat steps 1 and 2 I need help writing the code for this utility any help will be greatly appreciated |
script
Python script?
I might be able to help if Python is OK and you have it installed. I'm not very good with bash scripts. |
Moved: This thread is more suitable in the Programming forum and has been moved accordingly to help your thread/question get the exposure it deserves.
|
Here's a start. There are several things that will need to change such as what name you'd like to give the backup file and where to place it. Let me know if you are interested in finishing this. It takes theee input directory and makes a tar.gz compressed archive.
Code:
#! /usr/bin/env python |
Quote:
Code:
#! /usr/bin/env python Code:
tar = tarfile.open(backup_file, "w:gz") "w:bz2" : tar.bz2 file "w" : uncompressed tar file |
Thats pretty good Mr Banana. I didn't know Python had a tar module. Your programming style is more concise also. I'm beginner/intermediate with Python. Interesting to see how someone with more experience approaches it.
May I also suggest that the OP does this as a cron job. Put the script in your crontab and run it daily or weekly. That saves the hassle of having to do it daily and saves your a$$ if you get lazy and forget to backup. ;) Thanks, JB |
Thanks JBull, python is my favorite language by far, always fun to program in it. This board is very good for learning, answering questions and reading other peoples answers is the best way to learn in my opinion.
PS: I wasn't sure if it had a tar module until I checked Python Library Reference :) |
here's an awk script...
Code:
awk 'BEGIN{ |
All times are GMT -5. The time now is 11:17 PM. |