Skip to content

Instantly share code, notes, and snippets.

@pol
Last active August 29, 2015 14:27
Show Gist options
  • Select an option

  • Save pol/88b7a0e6d5fc9c2220a1 to your computer and use it in GitHub Desktop.

Select an option

Save pol/88b7a0e6d5fc9c2220a1 to your computer and use it in GitHub Desktop.
#!/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
@pol

pol commented Aug 19, 2015

Copy link
Copy Markdown
Author

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).

@pol

pol commented Aug 19, 2015

Copy link
Copy Markdown
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