Skip to content

Instantly share code, notes, and snippets.

@kopiro
Last active February 26, 2017 11:29
Show Gist options
  • Save kopiro/e01a2f98adec6bc50bbfb6716216a235 to your computer and use it in GitHub Desktop.
Save kopiro/e01a2f98adec6bc50bbfb6716216a235 to your computer and use it in GitHub Desktop.
S3 Backup in Bash
#!/bin/sh
# 0 2 1 * * /root/agent.sh
TIME=`date +%Y-%m-%d`
mkdir -p "/tmp/backup"
tar -cpzf "/tmp/backup/uploads.tar.gz" /var/www/uploads
tar -cpzf "/tmp/backup/other.tar.gz" /var/www/other
mysqldump -u root -p[PASS] [DBNAME] > "/tmp/backup/dump.sql"
aws s3 cp /tmp/backup "s3://[BUCKET]/backups/$TIME" --recursive
rm -rf /tmp/backup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment