Created
August 31, 2016 16:38
-
-
Save aaronott/fd4e5da123ee6e02a1bed898c4852bdf 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 | |
SOURCEDIR=/path/to/docroot | |
DESTDIR=/path/to/backup/dir | |
NAME=<site-name> | |
RETENTION=2 | |
let MMIN=($RETENTION*60*24)-180 | |
DATE=`date +%Y-%m-%d-%H-%M` | |
EXCLUDE="" | |
if [ ! -d $DESTDIR ] | |
then | |
/bin/mkdir -p $DESTDIR | |
fi | |
/usr/bin/find $DESTDIR -type f -name '*.tar.gz' -mmin +$MMIN | xargs /bin/rm -rf | |
/bin/tar -czf $DESTDIR/$NAME-$DATE.tar.gz $SOURCEDIR `if [[ -n "$EXCLUDE" ]]; then find $EXCLUDE -maxdepth 0 -print0 | while read -d $'\0' file; do echo " --exclude $file"; done; fi` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment