CDMoyer's
Ramblings


15
Dec

Quick, Cheap and Simple: Backups with s3sync

Here are some quick notes on the step-by-step process I used to set up automated backups to Amazon’s S3 on my linux server. Not much is Ubuntu, or even linux, specfic, so it should be quite applicable for other platforms.

Create an amazon s3 account

Get s3sync

 sudo apt-get install ruby
 sudo apt-get install libopenssl-ruby
  cd ~
  wget http://s3.amazonaws.com/ServEdge_pub/s3sync/s3sync.tar.gz
  cd /usr/local
  sudo tar xzfv ~/s3sync.tar.gz

Configure s3sync

  cd /usr/local/s3sync
  cp s3config.yml.example s3sync.yml

Get SSL certs

 wget http://mirbsd.mirsolutions.de/cvs.cgi/~checkout~/src/etc/ssl.certs.shar?rev=1.10;content-type=application%2Fx-shar

Create bucket

  cd /usr/local/s3sync
  ./s3cmd.rb -s createbucket bucketname

Now you can sync

  cd /usr/local/s3sync;
  ./s3sync.rb -snrv --delete /etc/ bucketname:etc
 ./s3sync.rb -srv --delete /etc/ bucketname:etc

Cron it

I created a simple script and threw it in /etc/cron.weekly/s3backup

 #!/bin/bash
SARGS=“-vs” # you can add -n in here for testing, remove s for non-ssl, remove verbosity, etc SENDMAIL=/usr/sbin/sendmail EMAIL=myuser@mydomain cd /usr/local/s3sync echo -e “To: ${EMAIL}\nSubject: s3backup results\nContent-type: text/plain\n\n” > /tmp/s3backup.log pg_dumpall -Ucdmoyer | gzip > /opt/www/db/pg_dumpall.gz #/root/.pgpass is needed for this ./s3sync.rb ${SARGS} —delete -r /etc/ bucketname:etc » /tmp/s3backup.log ./s3sync.rb ${SARGS} —delete -r /opt/ bucketname:opt » /tmp/s3backup.log ./s3sync.rb ${SARGS} —delete -r /var/backups/ bucketname:var/backups » /tmp/s3backup.log cat /tmp/s3backup.log | ${SENDMAIL} “${EMAIL}”

Notes & Cost

This was originally done on Ubuntu Gutsy Gibon, so your mileage may vary.

Things I did:

Total Cost: $0.29 so far, and it will cost me $0.15 at the end of the month. It seems to cost a bit less than a penny each time I sync.

Posted In: · linux    · s3    · aws   
Comments