In previous post I showed you how easy it is to use S3 as a mounted volume in Ubuntu.

But sometimes you just want to sync content of a folder to a bucket in S3.. Here are the steps to success:

 

First you need to get boto-rsync from https://github.com/seedifferently/boto_rsync

To put the files in a folder called boto:

git clone git://github.com/seedifferently/boto_rsync boto

Then you want to make a script that does the job for you instead of typing the command each time.

boto-rsync is pretty simple – the usage: boto-rsync [OPTIONS] SOURCE DESTINATION makes it very easy.

Follow these easy steps to create one executable file:

vi autoboto.sh

paste these lines:

#!/bin/bash
export AWS_SECRET_ACCESS_KEY=your key
export AWS_ACCESS_KEY_ID=your key
/usr/bin/python /home/ubuntu/boto/bin/boto-rsync /path/to/upload/ s3://bucketname/

The bucket must exist.

now do

chmod +x autoboto.sh

Done and done. You should test the script on a folder with a small set of files before using it on the BIG folder you want to backup.

Or read the manual 🙂

-n, --dry-run No files will be transferred, but informational
 messages will be printed about what would have
 happened.

The usuage is

./autoboto.sh (remember to change /path/to/upload/

You can add this to crontab to perform a sync each night like:

sudo crontab -e
00 00 * * * /home/ubuntu/boto/bin/run.sh >> /var/log/boto.log

 

Leave a Reply

Your email address will not be published. Required fields are marked *