mirror of
https://github.com/ChrisSewell/MySQL-backup-to-Amazon-S3.git
synced 2025-07-01 18:47:26 -04:00
Update mysqltos3.sh
This commit is contained in:
@ -9,6 +9,8 @@ MYSQLPASS=password
|
||||
S3BUCKET=bucketname
|
||||
FILENAME=filename
|
||||
DATABASE='--all-databases'
|
||||
# the following line prefixes the backups with the defined directory. it must be blank or end with a /
|
||||
S3PATH=mysql_backup/
|
||||
# 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=
|
||||
#tmp path.
|
||||
@ -32,16 +34,16 @@ echo "Done compressing the backup file."
|
||||
|
||||
# we want at least two backups, two months, two weeks, and two days
|
||||
echo "Removing old backup (2 ${PERIOD}s ago)..."
|
||||
s3cmd del --recursive s3://${S3BUCKET}/previous_${PERIOD}/
|
||||
s3cmd del --recursive s3://${S3BUCKET}/${S3PATH}previous_${PERIOD}/
|
||||
echo "Old backup removed."
|
||||
|
||||
echo "Moving the backup from past $PERIOD to another folder..."
|
||||
s3cmd mv --recursive s3://${S3BUCKET}/${PERIOD}/ s3://${S3BUCKET}/previous_${PERIOD}/
|
||||
s3cmd mv --recursive s3://${S3BUCKET}/${S3PATH}${PERIOD}/ s3://${S3BUCKET}/${S3PATH}previous_${PERIOD}/
|
||||
echo "Past backup moved."
|
||||
|
||||
# upload all databases
|
||||
echo "Uploading the new backup..."
|
||||
s3cmd put -f ${TMP_PATH}${FILENAME}.tar.gz s3://${S3BUCKET}/${PERIOD}/
|
||||
s3cmd put -f ${TMP_PATH}${FILENAME}.tar.gz s3://${S3BUCKET}${S3PATH}/${PERIOD}/
|
||||
echo "New backup uploaded."
|
||||
|
||||
echo "Removing the cache files..."
|
||||
|
Reference in New Issue
Block a user