simple automated backup of apache (your websites) - Printable Version +- Linux-Noob Forums (https://www.linux-noob.com/forums) +-- Forum: Linux Server Administration (https://www.linux-noob.com/forums/forum-8.html) +--- Forum: LAMP (https://www.linux-noob.com/forums/forum-83.html) +--- Thread: simple automated backup of apache (your websites) (/thread-2965.html) |
simple automated backup of apache (your websites) - anyweb - 2004-12-29 This will create a dated and compressed tar backup once a week, of everything in /usr/local/apache into the /backup/ directory. This certaintly may be useful considering the amount of worms floating around at the moment (like Santy, which overwrite all php and html files with rubbish) ** this assumes you have your websites in /usr/local/apache as per the apache/mysql/php compilation howto in this forum, obviously, if they are not in that path, edit the path to point to your websites/code ** (thanks Kobras for advising me here) Simply do as follows: Code: vi /etc/cron.weekly/apache.cron ok now paste the following into this blank file Code: #!/bin/sh save the file and now make it executable Code: chmod +x /etc/cron.weekly/apache.cron ok, create the /backup directory Code: mkdir /backup and test the script (to see that it works) Code: /etc/cron.weekly/apache.cron if all goes well you should see a file like this in your /backup directory Quote:[root@www root]# ls -alsrxh /backuptotal 140M ok that's it ! all done, now you may want to write another script to 'auto delete' a file if older than two weeks, otherwise your hard disc may soon fill up with backups. cheers anyweb simple automated backup of apache (your websites) - KobrAs - 2004-12-29 nice anyweb :) im going to write some "auto delete" tool but i need your help. how should this tool delete the backup ? once on at two weeks ? or ? simple automated backup of apache (your websites) - anyweb - 2004-12-29 the tool should check /backup and if three or more files exist then delete the last (oldest) ones so that there is only two remaining for example lets imagine the /backup dir has the following files Quote:[root@www root]# ls -alsrxh /backuptotal 144M then it should 'see' that there are three files, and that 144M apache_backup_Dec_15_2004.tar.bz2 is the oldest, it should then automatically delete 144M apache_backup_Dec_15_2004.tar.bz2 This will mean that you always should have at least TWO weeks worth of backup for your websites. ok ? cheers anyweb simple automated backup of apache (your websites) - z0ny - 2004-12-29 Try this: Code: #!/bin/sh Note: This keeps the latest $KEEP files concerning creation time, not filename! This should suit your needs anyways. simple automated backup of apache (your websites) - anyweb - 2004-12-29 thanks z0ny my script now looks like this Code: #!/bin/sh cheers anyweb simple automated backup of apache (your websites) - KobrAs - 2004-12-29 the mailing script :) #!/bin/sh #setting paths and files #setting log path tmp=$tmp file=apache_backup_`date | awk '{print $2}'`_`date | awk '{print $3}'`_`date | awk '{print $6}'`.tar.bz2 >>$tmp/apachebackup.txt space=`du -sh $file | awk '{print $1}'` date=`date` echo -n "" >$tmp/apachebackup.txt echo "Hi anyweb, i am the backup tool from linux-noob.com, i got a new backup for you" >>$tmp/apachebackup.txt echo "the new file is $file and has $space" >>$tmp/apachebackup.txt echo "the date is $date" >>$tmp/apachebackup.txt cat $tmp/apachebackup.txt | mail anyweb@linux-noob.com -s 'new backup' rm -rf $tmp/apachebackup.txt echo -e "Enjoy" simple automated backup of apache (your websites) - hijinks - 2004-12-29 and of course the best backup is placing that tar file on another computer right?? :) simple automated backup of apache (your websites) - Guest - 2004-12-29 if you use Debian, take a look at the rsnapshot package. it's a marvellous backup solution. simple automated backup of apache (your websites) - anyweb - 2004-12-30 yes i want to ftp this backup file to another computer on the network once a week (after the latest file is created) let's say that:- the ftp address is 100.0.0.2 the port is 21 the user is ftpuser the password is ftppassword how can i get the backup script to automagically ftp the 'latest' or just created backup file to the ftp server given the info above ? i look forward to the answer cheers anyweb simple automated backup of apache (your websites) - z0ny - 2004-12-30 On the LAN I would create a passwordless SSH login (key secured) and "upload" it via SCP. |