Need a break from coding? - Then try a boating holiday in Europe.
Published 22.May.2008
Several years ago I wrote the article How to backup your data using TAR and GZIP, and this is still the method I use to backup my personal files, and my company uses this technique to backup our cliens project files. The only difference is instead of burning backup files onto CD-ROM, we now push the backups offsite to the Amazon S3 storage service.
This article discusses how to encrypt your backups before sending them to Amazon S3, and the easiest method of transferring your files to and from your S3 account. Amazon S3 has proved itself to be a very cheap solution for small businesses and home users wanting to store files offsite. You can store an unlimited amount of data for only 15¢ per gigabyte per month, that's around 7 pence, even for companies with very large data files it is still a reasonable solution worth considering.
As encrypting your backup is easy and free, it's something you should take the time to set-up. The following example assumes you are using my backup technique and that you want to automate the encryption and transfer steps.
To encrypt your backup file, you will need to download and install OpenSSL, which contains several encryption schemes, we are going to use the Blowfish symmetric block cipher, with a large random key.
At the end of backup procedure, we have a file called backup.tar.tgz, which we need to encrypt using OpenSSL, the sample code below goes into your backup batch file.
openssl enc -bf -salt -in backup.tar.tgz -out backup.s3 -pass yourpassword
The resulting file backup.s3 is the encrypted file, and is the one which we need to upload to the Amazon S3 service. You will need to substitute yourpassword with a long random password, I suggest using one of Steve Gibson's Perfect Passwords, which will generate a 63 random alpha-numeric password.
Amazon provides programming services to interact with all its web services, including S3, but the easiest way I have found of interacting with your S3 account is to install a $20 piece of software called Jungle Disk.
Jungle Disk runs on your local machine as a WebDAV server, and installs itself as a drive letter (typically J:), allowing you to access your files directly from Windows Explorer, which also means you can use the DOS xcopy command to automate the transfer of your files to S3. You simply copy your files to your Jungle Disk drive letter, and let it handle the uploading process.
xcopy backup.s3 j:\ /V
The /V switch in the above example, tells xcopy to verify each file as it is written to the destination file to make sure that the destination files are identical to the source files.
A complete backup and send off-site batch file, might look something like:-
tar -cv --file=backup.tar d:/data*
gzip -9 < backup.tar > backup.tar.tgz
del backup.tar
openssl enc -bf -salt -in backup.tar.tgz -out backup.s3 -pass yourpassword
xcopy backup.s3 j:\ /V
Bookmark this article at :-
If the information you have found here helps to strengthen your business, or has saved you lot's of time, and you'd like to show your appreciation, consider making a small donation.