Created
July 18, 2016 13:33
-
-
Save robjbrain/cbf47487b8e531e122621c42ee4a687c 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
#!/usr/bin/env bash | |
# Backup uploaded files | |
aws s3 sync ~sortitoutsi/httpdocs/public/uploads/files s3://sortitoutsi/files --size-only --storage-class 'STANDARD_IA' | |
# Backup uploaded images | |
aws s3 sync ~sortitoutsi/httpdocs/public/uploads/images s3://sortitoutsi/images --size-only --storage-class 'STANDARD_IA' | |
# Backup career stats | |
aws s3 sync ~sortitoutsi/httpdocs/public/uploads/careerstats s3://sortitoutsi/careerstats --size-only --storage-class 'STANDARD_IA' | |
# Backup comment attachments | |
aws s3 sync ~sortitoutsi/httpdocs/public/uploads/comment_attachments s3://sortitoutsi/comment_attachments --size-only --storage-class 'STANDARD_IA' | |
# Backup liveupdate files | |
aws s3 sync ~sortitoutsi/httpdocs/public/uploads/liveupdate s3://sortitoutsi/liveupdate --size-only --storage-class 'STANDARD_IA' --exclude '*.xml' | |
# Delete local liveupdate files older than 30 days | |
find ~sortitoutsi/httpdocs/public/uploads/liveupdate/* -mtime +30 -exec rm {} \; | |
# Delete empty directories in the liveupdate folder | |
find ~sortitoutsi/httpdocs/public/uploads/liveupdate/ -empty -type d -delete | |
# Backup mysql with one month expiration | |
aws s3 cp /usr/tmp/mysql.exports/sortitoutsi.sql.gz s3://sortitoutsi/mysql_backups/sortitoutsi-`date +%d-%m-%Y`.sql.gz --storage-class 'STANDARD_IA' --expires `date +%s -d "next month"` | |
# TODO Backup megapacks | |
#aws s3 sync megapacks s3://sortitoutsi/megapacks --storage-class 'STANDARD_IA' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment