23 November 2006
s3backup is a perl script designed for managing backups to the
Amazon S3 web service.
An account is required with Amazon S3 in order to use this script, and that does cost money. However, for smaller sites the cost
is negligable compared to the piece of mind of having decent off-site backups.
Note: The quality of the backups made are entirely up to the user of the script. All the script ever does is uploads
a single file to S3, and allows retrieval of the file. It does do validation of the uploaded file to ensure that it is uploaded
correctly. However, what it uploads is up to the administrator of the system it is being run on.
If you are using the S3Backup script for your system backups, please send me an email to graham-s3backup@grahamcox.co.uk. I like to
be informed about who is finding my software useful.
MD5 checksums
- 383eebf02ebd3f082d3516ea799bede7 s3backup-0.1.tgz
- 2ebdbe2c45de066131a86fb9dc3c1491 s3backup-0.1.tgz.asc
- 751419260aa954499f7abaabaa882bbe LICENSE
Installation of the package is simply a case of expanding the tarball to a directory on your system, and ensuring that the prerequisit
perl modules are all installed. I recommend installing the package to /usr/local/s3backup, as there are a number of files that are required
to be in the same folder as the perl script.
Required modules
- Crypt::SSLeay
- Getopt::Lucid
- Config::ApacheFormat
- File::Slurp
- MIME::Base64
- Date::Manip
- Digest
- Digest::SHA1
Notes
If the Crypt::SSLeay perl module is not installed then the program will appear to function, but will be unable to communicate with the Amazon S3 service.
Also, please make sure that your computer clock is set to the correct time. An incorrect timestamp will cause your communications with the Amazon S3 service
to be rejected. The safest way to ensure your computer clock is correct is to run an
NTP client
Before using the program, a
configuration file is required. An example of this file is supplied in the docs folder in the archive.
This file specified 1 or more backups that the program knows about, in the same format as the Apache config files.
The config file location can be specified on the command line, or if this is not the case it defaults to either ~/.s3backup or /etc/s3backup.
If you specify a file that does not exist then it will fail, and will not return to looking at the default locations.
When you execute the script, you can optionally supply a number of command line parameters to tell it what to do. If you don't specify
any then it will default to doing a backup for each entry in the config file.
The parameters you can specify are as follows:
- --config (-c)
- Alternative config file to use
- --action (-a)
- The action to perform. Available actions are backup, retrieve, trim and list. If no action is specified then the default used is backup
- --backup (-b)
- The name of the backup to work on. If no backup is specified then the default is to use each in turn
- --output
- The filename to store the retrieved file into. This file is required if you are retrieving a file, and is ignored if you are doing anything else. This file Must not exist.
A configuration file is required to tell the script what to back up. This configuration file will normally live in either ~/.s3backup or /etc/s3backup, but an alternative location can be specified when executing the script.
The configuration file is a simple text file in the same format as the Apache config files. This allows for general options to be specified, which are then used by each backup, but can be overridden by the individual backups.
Example Config File
AccessKeyId ThisIsMyAmazonS3AccessKeyID
SecretAccessKey ThisIsMyAmazonS3SecretAccessKey
Bucket backups
History 10
<Backup example>
File /var/backups/backup1.gz
</Backup>
<Backup example2>
File /var/backups/backup2.gz
History 1
</Backup>
<Backup example3>
Bucket websites-backups
file /home/website/public_html.tgz
History 10
</Backup>
Config File Definitions
One backup definition exists for every <Backup> block defined in the config file.
All settings declared outside of any blocks will be present in every following block, exactly the same as in certain blocks in Apache config files.
The contents of each block is totally seperate from the contents of every other block. Note that this means it is possible to use different S3 account details
in different blocks in the same config file, if you want.
In the above example, the following config entries are set:
- Backup example
- AccessKeyId ThisIsMyAmazonS3AccessKeyID
- SecretAccessKey ThisIsMyAmazonS3SecretAccessKey
- Bucket backups
- History 10
- File /var/backups/backup1.gz
- Backup example2
- AccessKeyId ThisIsMyAmazonS3AccessKeyID
- SecretAccessKey ThisIsMyAmazonS3SecretAccessKey
- Bucket backups
- History 1
- File /var/backups/backup2.gz
- Backup example3
- AccessKeyId ThisIsMyAmazonS3AccessKeyID
- SecretAccessKey ThisIsMyAmazonS3SecretAccessKey
- Bucket website-backups
- History 10
- File /home/website/public_html.tgz
The available config file definitions are:
- AccessKeyId
- Your Access Key ID on the Amazon S3 service
- SecretAccessKey
- Your Secret Access Key on the Amazon S3 service
- Bucket
- The bucke to store this backup in on this account
- History
- The number of files to store for this backup before they start to be trimmed automatically. Set this to 0 to disable trimming
- File
- The file to store
Copyright (C) 2006 Graham Cox
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
GNU GPLv2