simple-backup-script
hi ,
folks i am writting this coz it may be help full to any new guy. the purpose of this script is to tar the required files and ftp them to any remote location. it is tested on rh9 platform, as dont have any other. _____________________________________________________ #!/bin/sh DATE=`date +%F` ###this will set current date to DATE value echo " so the file is present we will tar all important files" echo " the important files is user information and group imformation" echo " user home directories" echo " users mails /var/spool/directory" ############ #### now creating real back up ########### tar -cvf "$DATE.tar" "/etc/hosts" "/var/spool/mail" "/etc/resolv.conf" ### creates DATE.tar file tar -vrf "$DATE.tar" "/etc/passwd" "/etc/shadow" "/etc/group" "/var/www" ## append to files tar -vrf "$DATE.tar" "/etc/httpd/conf/httpd.conf" "/var/named" "/etc/named.conf" ##### YOU can also check if the DATE.tar file was created or not ########### ### DATE.tar file will be u r current date eg:- 2005-04-25.tar ########### ##### u can also gzip it if u want to compress it ###### echo "Now we will ftp the created backup File" ftp -n <Hostname or IP address/ of FTP server> <<abcdef user <username> <password> ls #### it optional i am checking and changing directory on cd back ### ftp server bin ### switching to binary format hash #### enabling hash printing put "$DATE.tar" ### uploading u r backup tar file bye #### logging out of ftp server abcdef exit 0 ### end of script _______________________________________ this was very scrapy but working script.... later it can also be added to crontab entry for automation. set all executable permissions to script suppose our script is backup.sh at /var/back/ chmod +x /var/back/backup.sh ##command to set executable permission on file ____________________ just type at console it will open a text editor usually i work with vi crontab -e _________ now in that open editor type 30 2 * * 1,3,5,7 /var/back/backup.sh ####eg :- /var/back/back.sh -> pacth to file now save and close ___________________________ this will execute u r back up script every monday, wed,friday, sunday at night 2:30 ______________________________________________ now if any one want to modify or add or beautify this u can surely do it. thanks in advance. |
Why did you post this again? You already posted it in this very same forum a few days back found here: http://www.linuxquestions.org/questi...hreadid=316873
Read our rules you agreed to when registering here: http://www.linuxquestions.org/rules.php Specifically where it states to not crosspost the same discussion, threads or questions more than once in the same forum or any other forum, etc. :tisk: :tisk: :tisk: |
All times are GMT -5. The time now is 05:43 PM. |