1
======================
#!/bin/bash
NOWDATE=`date +%Y-%m-%d`
BACKUPNAME="$NOWDATE.sql.gz"
echo "Creating backup of database finances to $BACKUPNAME"
mysqldump –user=user –password=password database_name | gzip -9 > $BACKUPNAME
echo "Succesfully created database backup"
echo "Uploading backup to Amazon S3 bucket…"
/usr/local/bin/s3cmd put $BACKUPNAME s3://path /to /file/$BACKUPNAME
echo "Successfully uploaded backup to S3"
echo "Deleting backup file…"
rm $BACKUPNAME
echo "Done"
2
==========================
1 ;;; Amazon RDS configuration
2 storage.mysqlAmazonRds.storage = mysql
3 storage.mysqlAmazonRds.dbinstance = <dbinstancename>
4 storage.mysqlAmazonRds.region = REGION_EU_W1
5 storage.mysqlAmazonRds.dbinstanceclass = db.m1.small
6
7 ;;; we want to backup all databases on server
8 storage.mysql.dbname = *
9
10 ;;; connect to mysql server on RDS to build backup
11 ;storage.mysql.port = 3306
12 storage.mysql.user = username
13 storage.mysql.password = userpassword
14
15 ;;; databases will be backuped under this folder
16 storage.mysql.basedir = "~/Backups/amazonRdsDb"
17
18 compare.sqlite.file="~/Backups/xtbackupCompare.db"
19
20 storage.s3.bucket=<Amazon S3 bucket name>
21
22 ;storage.s3.key.access=<access key>
23 ;storage.s3.key.secret=<secret>
24
25 storage.s3.update=true
26
27 ;;; let us put everything together
28 engine.outputs[]=cli
29 engine.local=mysqlAmazonRds
30 engine.remote=s3
31 engine.compare=sqlite
line 4: you can specify where the backup instance should be created
line 5: you can specify class of instance, allows some saving if you use smaller instance that used for the live instance
line 18: new need to set compare service, we use sqlite version(only one implemented at the time of writing this) set it up in a persistent space (not tmp)
line 22-23: Generate "Access Keys" in Security Credentials in your AWS console
This needs to be filled in if you want ot use s3 as storage, however preferred way is to use private INI file that can be stored in the more secure folder with limited access. That way you can avoid accidentally committing your AWS credentials to potentially public repositories and losing $$$ in the process http://pulse.me/s/13oajD.
So if you do not use separate INI file please uncomment this lines and fill in credentials.
line 25: should upload/remove of data be executed? (yes/no/simulate)
yes - will transfer data to S3
no - will not start update process
simulate - will output progress, but will not really transfer data
0 comments:
Post a Comment