Skip to content

Instantly share code, notes, and snippets.

@valeriu
Created August 17, 2013 02:58
Show Gist options
  • Select an option

  • Save valeriu/6255027 to your computer and use it in GitHub Desktop.

Select an option

Save valeriu/6255027 to your computer and use it in GitHub Desktop.
Backup incrémentales
WEEK=$(date +%V)
BKDIR="/var/www/cron/backup/$WEEK"
BKSITE="/var/www/site"
BKDEL="/var/www/cron/backup/*"
if [ ! -d "$BKDIR" ]; then
mkdir -p $BKDIR
tar -czf $BKDIR/bk-full.tar.gz -g $BKDIR/bk_infos.txt $BKSITE
fi
tar -czf $BKDIR/bk-$(date +%d-%m-%Y).tar.gz -g $BKDIR/bk_infos.txt $BKSITE
find $BKDEL -mtime +14 -exec rm -r {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment