Skip to content

Instantly share code, notes, and snippets.

@knutov
Forked from nshopik/simple-backup.sh
Created June 25, 2014 14:08
Show Gist options
  • Save knutov/f5feacaf351c296dd9fe to your computer and use it in GitHub Desktop.
Save knutov/f5feacaf351c296dd9fe to your computer and use it in GitHub Desktop.
#!/bin/sh
cd /root/backup || exit
date=`date +%F`
days=10
host=`hostname`
nice rsync -aR --delete --link-dest=$PWD/$host.current --exclude-from=exclude.list \
/etc/apache2 \
/var/www \
$host.$date && \
( rm -f $host.current; ln -s $host.$date $host.current ) && \
find $host.* -maxdepth 0 -type d -ctime +$(( $days - 1 )) -exec rm -r {} +
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment