How to backup to Amazon S3

## UPDATE 2017 ##
The method described below was in use 5 years ago. It may still work on your host, but there are more elegant ways to do this now. I keep it here for archive purposes only.
##############

Need to backup your Linux server files and databases to Amazon S3? Here is a great tool – http://s3tools.org/download

Follow the install instructions.

Once you set up your S3 bucket, you can use this bash script to copy files to the S3 bucket:


#!/bin/sh
#
## Lanexa.net - file name = BACKUP_s3.sh
## backup script to push archive files to Amazon S3 bucket
## 2012-01-04
#
# define where your backup files are stored locally on your server
FILEDIR=/BACKUP/files/
DBDIR=/BACKUP/mysql/
#
cd $FILEDIR
#
# use s3cmd to upload files to S3 instance
s3cmd put FILENAME s3://BUCKET-NAME/
#
cd $DBDIR
s3cmd put DATABASES s3://BUCKET-NAME/
#
# email a note to yourself that backup is complete
mail -s "backup files and databases copied to S3" youremail@address.com

Chris

Chris started building web sites and web applications in 1996, after installing Linux and discovering httpd. It was a career in freshwater fisheries and geographic information systems (GIS) that led Chris to the web, and to start Lanexa.net in 1998. Chris has a strong background in Linux/Unix systems administration, HTML, CSS, PHP, as well as Oracle and MySQL database administration. Chris is a proven leader, having lead the development of ecommerce platforms for Fortune 500 companies, as well as start ups. He is able to bridge the gap between Marketing and IT, and turn business requirements into development objectives, and he delivers results. When Chris is not working on web sites, he is usually chasing his kids around or playing mandolin. Finalist, San Diego Magazine's Top Tech Exec Awards, 2012, 2013 Council Member, Magento X-Commerce Merchant Council, 2011

Leave a Reply

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