Backing up a server to S3

AWS LogoIf you run a server of any kind then you should know how important it is to regularly backup the server. Now even though backing up the server is a great thing to do, it doesn’t do any good if the backup is in the same location as the server itself; if the building burns down, everything is gone. It is best to have an off-site backup location in another city or even state or country.

This is where Amazon’s S3 service comes in handy. S3 is a service where you can store data of any type for a low monthly fee ( $0.14 per Gigabyte at the time of this writing ). S3 uses “buckets” to store your data – think of a bucket as a directory. To get started, do the following:

  • Sign up for am Amazon account at
  • Log in at You will see a bunch of tabs at the top of the page. Click on the one for S3.
  • Create a new bucket and name it something relevant to what you are going to store inside of it.
  • Click on your name at the top-right of the page and select “security credentials”
  • Copy your access key and your security key (you can do this later – but just be aware of where they are)

Now you are set up to use Amazon’s S3. Next, you need to install a S3 client. I am running Ubuntu Server and the client I use is called s3cmd. To install s3cmd, do this (it should already be in your repository for Ubuntu Server):

sudo apt-get install s3cmd

After it is installed, you must configure the program (I did it as root since I will be running this program as root). To configure it, do this:

sudo s3cmd --configure

Go through the configuration wizard. Use the access and security keys you discovered above.

s3cmd has all kinds of options. The option I am using is the sync option since I will set the servers to sync every x amount of hours. If you want to learn about more s3cmd options, run this command:

s3cmd -h

The command I use to back up my servers is as follows (I run it as a cron job, but you can also run it manually):

s3cmd -rpH sync /home s3://my_bucket
  • the “r” option makes the sync go recursively (into sub-directories, etc)
  • the “p” option preserves permissions and ownership of files and dirs
  • the “H” option shows the file sizes in human readable format
  • “sync” tells it to sync between the server and s3
  • “/home” is the directory I am recursively backing up
  • “s3://my_bucket ” is the bucket location in S3 where everything will be backed up to.

2 Thoughts on “Backing up a server to S3

  1. Linda on March 8, 2012 at 10:42 pm said:

    How many TB one can store?. I am using [another service] to backup my business data.

Post Navigation