Amazon S3 provides a cheap solution and easy to use solution to back up your Linux server or files on the cloud. The Linux
s3cmd script lets you use
rsync to backup folders and files easily, and you can even choose to just backup files that have changed since the last backup.
You need to start by installing
s3cmd on your server. You can do this using
apt-get (Ubuntu) or
yum (Fedora or CentOS):
Next, you need to configure the application to use your AWS credentials. You can find your “Security Credentials” from the “My Account / Console” menu from the AWS site. Then, you need to run the
s3cmd --configure command. You’ll be asked to enter your AWS Access and Secret keys so the script can access your S3 buckets.
Once configured, the script will verify your settings to confirm it can connect to your AWS account to access your S3 buckets. You can then list the buckets on your account by entering the command:
You can then use the
s3cmd sync to
rsync files to your server. On my server, I use the following two commands to run the script from terminal or via a scheduled cron job:
The above commands will log the results of the transfer to the
s3_backup.log file. Looking at the last line of the file will reveal how many files were transferred, how long the transfer took and the size of the transfer:
Thank you Niraj. Nice precise information on howto set-up Amazon S3 as your back-up server using Linux. Within a couple of minutes and your information my Debian Linux was backing up!
Thanks for the short and sweet of it. Very useful information, I am looking into serving all my images and static files through CloudFront and this may come in handy.
Thank you very much! Very easy to set up and it works great. I’m doing this rather than use a pricey cloud backup service.
Dynamite tutorial, Niraj. With the addition of a small shell script, I’m now backing up key files on client sites, automatically and only when needed. Thanks much!
[…] First off, thanks to this helpful blog post for guidance. […]
Thank you so much Niraj 🙂 Please give me your mail Id so I can ask you any doubt in future.
Use the contact form on my site to get in touch.