Simple Python backup script for backing up files and MySQL dumps on Amazon S3.
This script requires boto. To install boto simply -
pip install boto
The script requires the following configuration parameters
AWS
- Access Key - aws_access_key
- Secret Key - aws_secret_key
- Bucket - aws_bucket
MySQL
- Hostname - mysql_hostname
- Username - mysql_username
- Password - mysql_password
- MySQL Dump Path - mysql_dump_path
Directories
You can backup as many directories as you like. Simply define it as a list and include the full path, e.g.
dirs = [
'/srv/www/domain1.com',
'/srv/www/domain2.com'
]
Databases
You can define the databases to be backed up the same way as the directories. Make sure your user has sufficient privilidges to access all databases, if more than one.
dbs = [
'domain1_app',
'domain1_blog',
]
Sample cron to run backup every day at 23.00.
0 23 * * * python ~/scripts/backup.py