Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: Disaster Recovery
PostPosted: Thu Jul 08, 2010 4:08 pm 
Offline
Senior Newbie
User avatar

Joined: Mon Jun 28, 2010 11:04 pm
Posts: 14
Website: http://johnlevandowski.com/
Location: Salt Lake City, UT
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.

Code:
#!/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=


Top
   
 Post subject:
PostPosted: Thu Jul 08, 2010 6:55 pm 
Offline
Senior Member

Joined: Fri May 02, 2008 8:44 pm
Posts: 1121
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.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group