Created
October 23, 2015 07:06
-
-
Save kasparsj/3e46825542fd9c0eed55 to your computer and use it in GitHub Desktop.
Backup a directory, copy latest backup to S3
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 | |
DIR=`/var/www` | |
NAME=`www` | |
DATE=`date +%d%m%y%H%M` | |
S3_BUCKET="s3://my-bucket" | |
# export files | |
tar czf /opt/backups/${NAME}_${DATE}.tar -C / ${DIR} | |
cp /opt/backups/${NAME}_${DATE}.tar /opt/backups/${NAME}-latest.tar | |
# remove backups older than 5 days | |
find /opt/backups/${NAME}* -mtime +5 -exec rm {} \; | |
# sync to amazon | |
aws s3 cp /opt/backups/${NAME}-latest.tar ${S3_BUCKET} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment