Disaster Recovery

I wanted to get some opinions on my linode disaster/recovery plan. I believe in the practice to only backup what is not replaceable. So I won't backup core system files/applications.

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=

1 Reply

Even if you don't back up system files, it can be very handy to keep a list of the packages you've installed. Then you'll be able to deploy a brand new linode, apt-get or yum install all your packages, put your configuration files back in /etc, and see everything working exactly as before. It should take no more than 10 minutes to restore a LAMP stack using this method, plus the time it takes to copy your webapp and database.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct