Prototype for the time machine similar solution as you noted in h-u-b whiteboard.

Andrew Jorgensen andrew.jorgensen at gmail.com
Thu Nov 16 15:57:02 GMT 2006


On 11/15/06, Sivan Greenberg <sivan at ubuntu.com> wrote:
> Have you given thought to how to make sure user's HD doesn't get filled
> with all the data that we back up? I suggest backup only the part of the
> file that was changed, there are couple of ways to do that already.

There's a simple trick involving rsync and hard-links, I've
implemented it once before.  I don't recall where I first read about
it but I'm pretty sure it's the method used by Drivish
<http://www.dirvish.org/>.  Here's my implementation (might be a
little dusty, haven't used or touched it in years.


#!/bin/sh
if [ ! -n "$BACKUP" ]; then
  echo "\$BACKUP must be defined."
  exit 1
fi
LATEST=$BACKUP`dir -1rt $BACKUP | tail -n 1`
CURRENT=$BACKUP`date +%Y%m%d-%H%M`
if [ "$LATEST" == "$CURRENT" ]; then
  echo "Please wait at least one minute."
  exit 1
fi
#du --summarize $BACKUP
if [ "$LATEST" != "$BACKUP" ]; then
  cp -Rl $LATEST $CURRENT
  chmod -R u+w $CURRENT
fi
rsync --recursive --checksum --copy-links --delete --delete-excluded
--include-from=$HOME/.syncs $HOME/ $CURRENT
chmod -R a-w $CURRENT


The above implementation only works when both source and target are on
the same fs but it could easily be adapted to work with a remote
rsync.

Basically you only backup a file if it's different than the current
backed-up file.  Another nice thing about it is it's file-system based
so you can literally just cd into the past.  Probably the nicest
thing, though, is that you can delete any snapshot and the others are
still there.



More information about the ubuntu-devel mailing list