Last active
September 1, 2015 20:52
-
-
Save khiet/5c6859fa982a07d5827b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BACKUP_DIR="/home/dumps/" | |
S3_PATH="s3://sunbury-dental-production/dumps/" | |
# create a dump | |
mysqldump -u$DB_USER -p$DB_PASSWORD dental_production > /home/dumps/production_dump_$(date +\%m\%d\%y).sql | |
# delete old dumps | |
find $BACKUP_DIR -type f -name "mysql_dump_*.sql.gz" -mtime +10 -daystart | xargs rm -rf | |
# sync with s3 | |
aws s3 sync $BACKUP_DIR $S3_PATH --delete | |
# crontab -e | |
PATH=/usr/bin:/bin:/usr/local/bin | |
BIN_DIR="/home/root/bin" | |
LOG_DIR="/home/root/log" | |
# every day at 00:00 | |
10 0 * * * /bin/bash $BIN_DIR/backup.sh >> $LOG_DIR/cron.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment