Skip to content

Instantly share code, notes, and snippets.

@JamesMcMahon
Last active January 2, 2016 15:29
Show Gist options
  • Save JamesMcMahon/8323556 to your computer and use it in GitHub Desktop.
Save JamesMcMahon/8323556 to your computer and use it in GitHub Desktop.
Timemachine style backup through rsync
#!/usr/bin/env bash
date=`date "+%Y-%m-%dT%H_%M_%S"`
backup_home=/mnt/storage/rsync-backup
rsync -azxqP \
--delete \
--link-dest=$backup_home/current \
--exclude='.gvfs' \
--delete-excluded \
/bin /boot /etc /home /lib /lib64 /opt /root /sbin /usr /var $backup_home/incomplete_back-$date \
> rsync.log 2>&1 \
&& mv $backup_home/incomplete_back-$date $backup_home/back-$date \
&& rm -f $backup_home/current \
&& ln -s $backup_home/back-$date $backup_home/current
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment