Disaster Recovery
Below is my script.
Basically I run automysqlbackup to backup mysql databases (backups stored in /root)
Then I run mysqlcheck for my database
Then the majority of the script transfers the backup to Amazon S3.
Specifically I would like feedback on the directories I am backup up.
/etc
/root
/var/www
/var/log
Are there directories that I am missing that I should backup?
My linode is used for as a LAMP server.
Thanks for your feedback.
In the event of a disaster I would reinstall my linode from scratch and them restore the above directories and mysql dbs.
#!/bin/bash
/root/backups/automysqlbackup.sh
mysqlcheck -Aao --auto-repair -u user -password | mail -s \
"Wordpress Database Check" user@example.com
# Set up some variables for logging
LOGFILE="/var/log/backup.log"
DAILYLOGFILE="/var/log/backup.daily.log"
HOST="host"
DATE=`date +%Y-%m-%d`
MAILADDR="user@example.com"
# Export some ENV variables so you don't have to type anything
export AWS_ACCESS_KEY_ID="KEY"
export AWS_SECRET_ACCESS_KEY="KEY"
export PASSPHRASE="PASS"
# How long to keep backups for
OLDER_THAN="2M"
# The source of your backup
SOURCE=/
# The destination
DEST="s3+http://bucket"
# Full Backup if last Full Backup Older Than
FULL_OLDER_THAN="1M"
# Volume Size for Backup Files
VOLSIZE="250"
# Clear the old daily log file
cat /dev/null > ${DAILYLOGFILE}
# Trace function for logging, don't change this
trace () {
stamp=`date +%Y-%m-%d_%H:%M:%S`
echo "$stamp: $*" >> ${DAILYLOGFILE}
}
trace "Backup for local filesystem started"
trace "... removing old backups"
duplicity remove-older-than ${OLDER_THAN} ${DEST} >> ${DAILYLOGFILE} 2>&1
trace "... backing up filesystem"
duplicity \
--full-if-older-than ${FULL_OLDER_THAN} \
--volsize=${VOLSIZE} \
--include=/etc \
--exclude=/root/.cache \
--include=/root \
--include=/var/www \
--include=/var/log \
--exclude=/** \
${SOURCE} ${DEST} >> ${DAILYLOGFILE} 2>&1
trace "Backup for local filesystem complete"
trace "------------------------------------"
# Send the daily log file by email
cat "$DAILYLOGFILE" | mail -s "Duplicity Backup Log for $HOST - $DATE" $MAILADDR
# Append the daily log file to the main log file
cat "$DAILYLOGFILE" >> $LOGFILE
# Reset the ENV variables. Don't need them sitting around
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
export PASSPHRASE=