Skip to content

Instantly share code, notes, and snippets.

@alanedwardes alanedwardes/s3_backup.sh
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.