[SATLUG] backup recommendations
tom weeks
tweeksjunk2 at theweeks.org
Sat Mar 3 00:31:21 CST 2007
On Friday 02 March 2007 14:04, Hector Bojorquez wrote:
> What exactly are the procedures for backing up an entire web server, in
> case of total failure?
> System--- Fedora 5
Typically on apache2 systems you wan to backup
/etc/httpd for your configs
/var/www for your web sites
/var/log/httpd for your logs
Write this little shell script, stick it in /root/bin/backupweb.sh, and chmod 755 it:
#!/bin/bash
# backupweb.sh
# Backs up base webserver config, /var/www and weblogs to
# /root/, and keeps the past 7 backups for reference
EMAIL=root at example.com
BACKDIR=/root/BACKUPS
DATE=$(date +%Y-%m-%d)
HOST=$(hostname -s)
DOBACKUP="tar czvf $BACKDIR/webserver-$DATE.tgz /var/www /var/log/httpd /etc/httpd"
mkdir -p $BACKDIR
$DOBACKUP > /dev/null 2>&1
STATUS=$?
if [ "$STATUS" -eq "0" ] ; then
find $BACKDIR -name webserver-*tgz -mtime +7 -exec /bin/rm {} \; >/dev/null 2>&1
echo | mail -s "$DATE: Backed up Webserver on server $HOST" $EMAIL
else
echo | mail -s "$DATE: Back up Webserver FAILED on server $HOST" $EMAIL
fi
If run nightly.. it will keep a nightly backup (back to 7 days) of your webserver
config, sites, and stock logfile locations (on many Linux distros).
Then to run it nightly from cron as root, as root type "crontab -e" and enter:
33 3 * * * /root/bin/backupweb.sh
(assuming you know how to use vi)
Of course this does not account for vhosts in other directories, databases, or
other one-off-ness.
Kind of down and dirty (no formal error checking, space checking, etc).. but hey..
it's late, I'm working out the mocha I just slammed at Borders, and you get
what you pay for.. ;)
Tweeks
More information about the SATLUG
mailing list