Kristian Lunde

www.klunde.net

Archive for the ‘amazonS3’ tag

Automated backups with Amazon S3

with 3 comments

I recently decided that I my half hearted backups to an external drive wasn’t really good enough, so I started to look at alternatives.

Note, this howto is for Mac and *nix system, if you need a windows version please try to google it.

I tried Crash plan, considered a extended dropbox plan but none of them seemed like the correct solution (still I love dropbox, its a great app). I ended up registering an Amazon S3 account.

After a quick google search I found this brilliant little blog post “Using Amazon S3 for personal backups” which describe how to use jetS3t to semi automate the synchronization of the iPhoto library on a Mac OSX.

I am not going to repeat the instructions found on the “Using Amazon S3 for personal backups” blog post, I did however have to do a few minor tweaks to get it to work, I also extended the functionality slightly, to enable a fully automated backup solution.

JetS3t has had a few releases since the “Using Amazon S3 for personal backups” article was written, I downloaded jets3t-0.8.1.zip. Adding the link of the jetS3t directory to the path in .profile didn’t work for me (I’m on Mac osX 10.6), so I added it to my .bash_profile file. You can find .bash_profile in /Users/YOUR-USERNAME/, you’ll have to replace YOUR-USERNAME with your proper username of course. Other than that I followed the examples in “Using Amazon S3 for personal backups”.

Once that was in place and worked properly I started to add some custom scripts.

1. Create a scripts directory in your home directory
2. Create a logs directory in the scripts directory

  1.  cd
  2. mkdir scripts
  3. mkdir scripts/logs

2. Navigate to your scripts directory and create a amazon-s3-backup.sh file.

  1. cd scripts
  2. touch amazon-s3-backup.sh

3. Use your favourite text editor to add the following code to the script

  1. #!/bin/bash
  2.  
  3. #Backup iPhoto
  4. synchronize.sh UP YOUR-IPHOTO-BUCKET /Users/YOUR-USERNAME/Pictures/iPhoto\ Library >> logs/amazon-s3-iphoto-backup.log
  5.  
  6. #Backup Documents
  7. synchronize.sh UP YOUR-DOCUMENTS-BUCKET /Users/YOUR-USERNAME/Documents >> logs/amazon-s3-document-backup.log

Replace YOUR-IPHOTO-BUCKET with the amazon S3 bucket you want to use, and replace YOUR-USERNAME with your username on your mac or *nix system. We pipe the output from the sync process to files in the logs directory, one log file for the iphoto and one log file for the documents process.

4. Edit your crontab. The crontab is a file where you can add files that you want to automatically execute on a regular basis.

  1. crontab -e

5. Add the script to your crontab, I’ve chosen to run it once a week at 20:00 every Sunday, which is expressed by (0 20 * * 0).

  1.  0 20 *  * 0 /Users/<em>YOUR-USERNAME</em>/scripts/amazon-s3-backup.sh

6. Save your cronjob

There you go, now you’ll backup your iPhoto library and Documents every Sunday at 20:00 as long as your computer is turned on and online. You can of course tweak when and how often you want to sync to Amazon S3, you can read more about scheduling cron jobs at wikipedia

Written by Kristian Lunde

May 21st, 2011 at 9:04 pm

Posted in Mac,Misc,Real Life

Tagged with , ,

Get Adobe Flash player