Skip to content

Instantly share code, notes, and snippets.

@alanedwardes
Last active August 29, 2015 14:01
Show Gist options
  • Save alanedwardes/4477ab692dd44646c90b to your computer and use it in GitHub Desktop.
Save alanedwardes/4477ab692dd44646c90b to your computer and use it in GitHub Desktop.
Small script for backing up stuff on a linux server.
#!/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