RevDisk.org Backup Script and cloud integration
Here's the basic sanitized version. It works and I'm happy with it for the moment. But I'm going to throw in some wait commands and break up the encrypted cloud upload into multiple segments, eventually. Otherwise, it spikes the disk i/o like no tomorrow. Doesn't break anything, but it trips off my automated warnings.
The required programs (besides tar) is gzip, openssl, ruby and s3sync. The following commands work on CentOS:
- yum install gzip openssl wget ruby
- wget http://s3.amazonaws.com/ServEdge_pub/s3sync/s3sync.tar.gz
- tar xzf s3sync.tar.gz
- rm s3sync.tar.gz
# To use this, you'll need tar, bzip2, openssl and s3sync
echo "Starting backup for $SERVER..."
rm -rf /root/$DIR/$DATE
mkdir -p /root/$DIR/$DATE
# System Files Backup
echo "Backing up /etc to $SERVER-etc.tar.gz"
tar -czPf /root/$DIR/$DATE/$SERVER-etc.tar.gz /etc
echo "Backing up /home to $SERVER-home.tar.gz"
tar -czPf /root/$DIR/$DATE/$SERVER-home.tar.gz /home
echo "Backing up /var/log to $SERVER-logs.tar.gz"
tar -czPf /root/$DIR/$DATE/$SERVER-logs.tar.gz /var/log
echo "Backing up /var/www to $SERVER-www.tar.gz"
tar -czPf /root/$DIR/$DATE/$SERVER-www.tar.gz /var/www
echo "Backing up all SQL databases to alldatabases.sql in /var/lib/mysql"
mysqldump -u root -pSQLPASSWORDHERE --all-databases > /var/lib/mysql/alldatabases.sql
echo "Backing up $SERVER MySQL files/databases to $SERVER-mysql.tar.gz"
tar -czPf /root/$DIR/$DATE/$SERVER-mysql.tar.gz /var/lib/mysql
# Cloud Upload
if [ $DATE = "Mon" ]
echo "Preparing package for the Cloud."
tar -czPf /root/serverbackup/upload/$DAY-backup.tar.gz /root/serverbackup/Mon
echo "Encrypting cloud package"
openssl aes-256-ecb -k CRYPTOPASSWORDHERE -in /root/serverbackup/upload/$DAY-backup.tar.gz -out /root/serverbackup/upload/$DAY.aes256
rm -rf /root/serverbackup/upload/$DAY-backup.tar.gz
echo "Launching to the S3 Cloud."
ruby /root/s3sync/s3sync.rb -v -s --delete /root/serverbackup/upload/ revdisk:/backup
echo "No cloud missions. Done."
This is my first experiment with cloud computing. Honestly, I've always been distrusting of "Software as a Service". In general it's leasing software and comes with a host of issues starting with cost and going up in importance from there. Amazon's pricing model isn't that bad. They offer a year of a free tier, which I'm not likely to exceed. After the free version expires, I'll likely keep my account. I'm happy to pay roughly $0.06 per backup, and I can stretch that out with compression and incremental backups. You can email me at revdisk at this domain.