Last active
August 29, 2015 14:01
-
-
Save alanedwardes/4477ab692dd44646c90b to your computer and use it in GitHub Desktop.
Small script for backing up stuff on a linux server.
This file contains 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 | |
# Get the day number | |
day="$(date +'%u')" | |
echo "Starting backup for day ${day}" | |
# Sync all data to S3, excluding git and svn folders | |
/usr/local/bin/aws s3 sync /path/to/folder s3://bucket/folder \ | |
--exclude "*.svn*" --exclude "*.git*" --delete | |
# Dump all MySQL data | |
/usr/bin/mysqldump -ubackup_user -pbackup_user_password --events \ | |
--all-databases | gzip > /path/to/dump/database_day_${day}.sql.gz | |
# Sync SQL data to S3 | |
/usr/local/bin/aws s3 sync /path/to/dump s3://bucket/dump |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment