Created
August 14, 2012 23:44
-
-
Save dengel/3353922 to your computer and use it in GitHub Desktop.
Mirror backup
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/bash | |
# | |
SITE="amiawesome.com" | |
FILE="$SITE-`date +%Y-%m-%d`.tgz" | |
KEEP=5 | |
# Update local mirror | |
wget -m -q http://$SITE/ | |
# Create new tarball | |
tar zcf $FILE $SITE/ | |
# Send notification | |
mail -s "Backup $SITE" [email protected] <<BUNNY | |
Please get the file located at: | |
http://lalalal.cl/backups/$FILE | |
Bye now! | |
BUNNY | |
# Remove oldest, but keep at most max | |
if [ $(ls -1 $SITE*.tgz | wc -l) -gt $KEEP ]; then | |
ls -1t $SITE*.tgz | tail -1 | xargs rm -v | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
++ date +%Y-%m-%d
++ wc -l
++ ls -1t amiawesome.com-2012-08-14.tgz amiawesome.com-2012-08-16.tgz amiawesome.com-2012-08-18.tgz amiawesome.com-2012-08-19.tgz amiawesome.com-2012-08-20.tgz