First commit

This commit is contained in:
Fabio Woxxy
2011-09-17 16:15:31 +02:00
commit e6e35e4f66
3 changed files with 99 additions and 0 deletions

30
mysqltos3.sh Normal file
View File

@ -0,0 +1,30 @@
#!/bin/sh
# Updates etc at: https://github.com/woxxy/MySQL-backup-to-Amazon-S3
# Under a MIT license
# dump all databases
mysqldump --quick --user=youruser --password=yourpassword --all-databases > ~/all-databases.sql
if [ $1 != month ]
then
if [ $1 != week ]
then
PERIOD=day
else
PERIOD=week
fi
else
PERIOD=month
fi
# we want at least two backups, two months, two weeks, and two days
s3cmd del --recursive s3://my-database-backups/previous_${PERIOD}/
s3cmd mv --recursive s3://my-database-backups/${PERIOD}/ s3://FoOlDB/previous_${PERIOD}/
# upload all databases
s3cmd put -f ~/all-databases.sql s3://my-database-backups/${PERIOD}/
# remove databases dump
rm ~/all-databases.sql