Last active
August 29, 2015 14:27
-
-
Save pol/88b7a0e6d5fc9c2220a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # | |
| # Novel (?) rsync incremental backup without hardlinks | |
| # Pol Llovet <pol.llovet@montana.edu> | |
| BACKUP_NAME=`date +%Y-%m-%d-%H%M%S` | |
| BASE="$WORK/backup" | |
| BACKUP="$BASE/$BACKUP_NAME" | |
| MANIFEST="$BASE/manifest" | |
| LOG="$BASE/current.log" | |
| BACKUP_MANIFEST="$MANIFEST/$BACKUP_NAME.manifest" | |
| v="$BASE/$BACKUP_NAME.log" | |
| CHECK_CURRENT="--dry-run -Wiah $HOME/ $BASE/current" | |
| CREATE_INCREMENT="-Wah --stats --compare-dest=$BASE/current $HOME/ $BASE/$BACKUP_NAME" | |
| UPDATE_CURRENT="-Wah --delete --stats $HOME/ $BASE/current" | |
| # make sure target dirs exist | |
| if [ ! -d $BASE ]; then mkdir -p $BASE; fi | |
| if [ ! -d $MANIFEST ]; then mkdir -p $MANIFEST; fi | |
| echo "========== $TS ==========" >> $LOG | |
| rsync $CHECK_CURRENT > $TS_MANIFEST | |
| if [ -s $BACKUP_MANIFEST ]; then | |
| rsync $CREATE_INCREMENT > $BACKUP_LOG | |
| rsync $UPDATE_CURRENT >> $LOG | |
| tar --remove-files -czf $BACKUP.tgz $BACKUP_LOG $BACKUP | |
| else | |
| # no changes, nothing to do, rm the empty manifest | |
| rm -f $TS_MANIFEST | |
| fi | |
| exit 0 |
Author
Author
I forgot how annoying full path rsyncs were. Hm. It should be relative.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The manifests should be in their own dir, they will need to all be grepped to find files. They could be temporarily gzipped (not really necessary though, it's all just txt).