Skip to content

Instantly share code, notes, and snippets.

@nshopik
Last active August 29, 2015 13:58
Show Gist options
  • Save nshopik/10134265 to your computer and use it in GitHub Desktop.
Save nshopik/10134265 to your computer and use it in GitHub Desktop.
simple-backup
#!/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