mirror of
https://github.com/ChrisSewell/MySQL-backup-to-Amazon-S3.git
synced 2025-07-01 18:47:26 -04:00
Merge branch 'master' of git://github.com/camelmasa/MySQL-backup-to-Amazon-S3
This commit is contained in:
12
mysqltos3.sh
12
mysqltos3.sh
@ -9,6 +9,8 @@ MYSQLPASS=password
|
|||||||
S3BUCKET=my-db-backup-bucket
|
S3BUCKET=my-db-backup-bucket
|
||||||
# when running via cron, the PATHs MIGHT be different. If you have a custom/manual MYSQL install, you should set this manually like MYSQLDUMPPATH=/usr/local/mysql/bin/
|
# when running via cron, the PATHs MIGHT be different. If you have a custom/manual MYSQL install, you should set this manually like MYSQLDUMPPATH=/usr/local/mysql/bin/
|
||||||
MYSQLDUMPPATH=
|
MYSQLDUMPPATH=
|
||||||
|
#tmp path.
|
||||||
|
TMP_PATH=~/
|
||||||
|
|
||||||
PERIOD=${1-day}
|
PERIOD=${1-day}
|
||||||
|
|
||||||
@ -17,12 +19,12 @@ echo "Selected period: $PERIOD."
|
|||||||
echo "Starting backing up the database to a file..."
|
echo "Starting backing up the database to a file..."
|
||||||
|
|
||||||
# dump all databases
|
# dump all databases
|
||||||
${MYSQLDUMPPATH}mysqldump --quick --user=${MYSQLROOT} --password=${MYSQLPASS} --all-databases > ~/all-databases.sql
|
${MYSQLDUMPPATH}mysqldump --quick --user=${MYSQLROOT} --password=${MYSQLPASS} --all-databases > ${TMP_PATH}all-databases.sql
|
||||||
|
|
||||||
echo "Done backing up the database to a file."
|
echo "Done backing up the database to a file."
|
||||||
echo "Starting compression..."
|
echo "Starting compression..."
|
||||||
|
|
||||||
tar czf ~/all-databases.tar.gz ~/all-databases.sql
|
tar czf ${TMP_PATH}all-databases.tar.gz ${TMP_PATH}all-databases.sql
|
||||||
|
|
||||||
echo "Done compressing the backup file."
|
echo "Done compressing the backup file."
|
||||||
|
|
||||||
@ -37,12 +39,12 @@ echo "Past backup moved."
|
|||||||
|
|
||||||
# upload all databases
|
# upload all databases
|
||||||
echo "Uploading the new backup..."
|
echo "Uploading the new backup..."
|
||||||
s3cmd put -f ~/all-databases.tar.gz s3://${S3BUCKET}/${PERIOD}/
|
s3cmd put -f ${TMP_PATH}all-databases.tar.gz s3://${S3BUCKET}/${PERIOD}/
|
||||||
echo "New backup uploaded."
|
echo "New backup uploaded."
|
||||||
|
|
||||||
echo "Removing the cache files..."
|
echo "Removing the cache files..."
|
||||||
# remove databases dump
|
# remove databases dump
|
||||||
rm ~/all-databases.sql
|
rm ${TMP_PATH}all-databases.sql
|
||||||
rm ~/all-databases.tar.gz
|
rm ${TMP_PATH}all-databases.tar.gz
|
||||||
echo "Files removed."
|
echo "Files removed."
|
||||||
echo "All done."
|
echo "All done."
|
Reference in New Issue
Block a user