Skip to content

Instantly share code, notes, and snippets.

@brianpursley
Created April 10, 2017 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianpursley/9ce82dd5ea1c33ed162984c99a3a88ea to your computer and use it in GitHub Desktop.
Save brianpursley/9ce82dd5ea1c33ed162984c99a3a88ea to your computer and use it in GitHub Desktop.
Script to backup a folder (/share) and capture incremental changes since the last backup in a timestamp-named folder
#!/bin/bash
ts=`date +%Y%m%d_%H%M%S`
rsync -rtm --compare-dest=/mnt/usb1/backups/snapshot --modify-window=2 /share /mnt/usb1/backups/$ts
find /mnt/usb1/backups/$ts -type d -empty -delete
rsync -rt --delete --modify-window=2 /share /mnt/usb1/backups/snapshot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment