Created
August 9, 2016 13:50
-
-
Save victorknust/560f29fd24215e512e0cbdf00d11637d to your computer and use it in GitHub Desktop.
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/sh | |
THESITE= "SITE-NAME" | |
THEDB="DATABASE-NAME" | |
THEDBUSER="DATABASE-USER" | |
THEDBPW="DATABASE-USER-PASSWORD" | |
THEDATE=`date +%d%m%y%H%M` | |
# export database | |
mysqldump -u $THEDBUSER -p${THEDBPW} $THEDB | gzip > /var/www/_backups/dbbackup_${THEDB}_${THEDATE}.bak.gz | |
# export files | |
tar czf /var/www/_backups/sitebackup_${THESITE}_${THEDATE}.tar -C / var/www/$THESITE/html | |
# remove backups older than 5 days | |
find /var/www/_backups/site* -mtime +5 -exec rm {} \; | |
find /var/www/_backups/db* -mtime +5 -exec rm {} \; | |
# sync to amazon | |
/usr/local/bin/aws s3 sync /var/www/_backups s3://BUCKET-NAME --delete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment