LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   small-article-backup (https://www.linuxquestions.org/questions/linux-general-1/small-article-backup-316873/)

ahmed4linux 04-25-2005 03:21 AM

small-article-backup
 
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.

__________________
Ahmed Mohiuddin
ms_dream@rediffmail.com

Technoslave 04-27-2005 10:40 AM

Not bad, but as a suggestion, you'd be better off using ssh/scp, or even better rsync.


All times are GMT -5. The time now is 01:12 AM.