I’ve been doing this for couple months now, and thought I’d share it with you guys. Christina Warren has written up some excellent instructions on how to back up MediaTemple’s Grid (gs) to your Amazon S3 account. There is also a video. I haven’t yet checked out the video, but I have a feeling it’s done very well.
S3Sync is used It is very, very simple to get everything set up and running. Just follow Christina’s step by step instructions, and you’ll be backing up to Amazon S3 in no time. If you are having any problems getting this set up just add a comment and I’ll help you out!
Below is an example of my backup.sh file. Feel free to customize it and use it.
[sourcecode language='php']#!/bin/sh
# A list of website directories to back up
websites=”joshprice.net”"
# The destination directory to backup the files to
destdir=/home/xxxxxx/users/.home/s3sync/s3backup
# The directory where all website domain directories reside
domaindir=/home/xxxxxx/users/.home/domains
# The MySQL database hostname
dbhost=internal-db.sxxxxxx.gridserver.com
# The MySQL database username – requires read access to databases
dbuser=xxxxxx
# The MySQL database password
dbpassword=xxxxxx
echo `date` “: Beginning backup process…” > $destdir/backup.log
# remove old backups
rm $destdir/*.tar.gz
# backup databases
for dbname in `echo ‘show databases;’ | /usr/bin/mysql -h $dbhost -u$dbuser -p$dbpassword`
do
if [ $dbname != "Database" ];
then
echo `date` “: Backing up database $dbname…” > $destdir/backup.log
/usr/bin/mysqldump –opt -h $dbhost -u$dbuser -p$dbpassword $dbname > $destdir/$dbname.sql
tar -czf $destdir/$dbname.sql.tar.gz $destdir/$dbname.sql
rm $destdir/$dbname.sql
fi
done
# backup web content
echo `date` “: Backing up web content…” >> $destdir/backup.log
for website in $websites
do
echo `date` “: Backing up website $website…” >> $destdir/backup.log
tar -czf $destdir/$website.tar.gz $domaindir/$website
done
#backup data folder
echo `date` “: Backing up data folder…” >> $destdir/backup.log
tar -czf $destdir/data.tar.gz /home/xxxxxx/users/.home/data
#backup pear folder
echo `date` “: Backing up pear folder…” >> $destdir/backup.log
tar -czf $destdir/pear.tar.gz /home/xxxxxx/users/.home/pear
echo `date` “: Backup process complete.” >> $destdir/backup.log
# The directory where s3sync is installed
s3syncdir=/home/xxxxxx/users/.home/s3sync
# The directory where the backup archives are stored
backupdir=/home/xxxxxx/users/.home/s3sync/s3backup
# The S3 bucket a.k.a. directory to upload the backups into
s3bucket=xxxxxx
cd $s3syncdir
./s3sync.rb $backupdir/ $s3bucket:[/sourcecode]







{ 1 trackback }