On Thursday 10 January 2008 19:53:30 Philipp Marek wrote: > Regarding the chroot version ... how do you access the repository? If > you get it via file:///, you'd better rsync it back too ... else the > "committed" data won't be there the second time.
Aha, of course. I now have a chroot-based version working from the snapshot, using the attached script. > Does the timestamp in the snapshotted directory change if you create > a file? I think it doesn't -- either snapshots give a problem, or > your test runs in below 1 second - so the timestamp isn't seen as > changed. You underestimate LVM snapshots. :-) I've modified the script to demonstrate that the snapshot is not being used, and that the snapshot obeys normal filesystem rules. It has to be modified with DO_CHROOT=0 to operate in softroot mode. Tarballs including debug output, FSVS_CONF, FSVS_WAA and repo included. > And please try a sync-repos before committing ... maybe that helps? No difference. I'm now pretty convinced that the softroot option doesn't work for commits. Fortunately, I now have the chroot-based method working, so I'm overjoyed. Full system backups from snapshot. Awesome, thanks! Ciao, Sheldon.
#!/bin/sh -x
DO_CHROOT=1
DEBUG="-d"
BACKUP_PREFIX=/media/backups
BINDS=/boot
ROOT=/dev/vgr1/root
SNAP=/dev/vgr1/rootsnap
SNAP_SIZE=1G # See lvcreate(8)
SNAP_MOUNT=`mktemp -d /tmp/fsvs.XXXXXX` # Should be in an ignored directory
depth_of () {
path=$1
}
errx () {
echo $* 1>&2
exit 1
}
set -e
lvcreate -s -L $SNAP_SIZE -n rootsnap $ROOT
mkdir -p $SNAP_MOUNT
mount $SNAP $SNAP_MOUNT
cd /
# DEBUG: proving that the backup is taken from the snapshot
sleep 2
ls -ld $SNAP_MOUNT/the-only-dir
[ -e $SNAP_MOUNT/the-only-dir ] && touch $SNAP_MOUNT/the-only-dir/from-snapshot
ls -ld $SNAP_MOUNT/the-only-dir
set +e
if [ "$DO_CHROOT" = "1" ]; then
binds="$BACKUP_PREFIX /etc/fsvs /var/spool/fsvs $BINDS"
for bind in $binds; do mount --bind $bind $SNAP_MOUNT/$bind; done
chroot $SNAP_MOUNT fsvs commit $DEBUG -m 'Automatic backup'
for bind in $binds; do umount $SNAP_MOUNT/$bind; done
else
# Take care; this assumes that SNAP_MOUNT/../.. is the root directory
FSVS_CONF=$SNAP_MOUNT/../../etc/fsvs \
FSVS_WAA=$SNAP_MOUNT/../../var/spool/fsvs \
fsvs commit $DEBUG -m 'Automatic backup' -o softroot=$SNAP_MOUNT
fi
set -e
# Also back up fsvs config and working copy administrative area
rsync -avI /etc/fsvs/ $BACKUP_PREFIX/system-fsvs.conf/
rsync -avi /var/spool/fsvs/ $BACKUP_PREFIX/system-fsvs.waa/
cd /
umount $SNAP_MOUNT
rmdir $SNAP_MOUNT
lvremove --force $SNAP
with-softroot-2.tar.gz
Description: application/tgz
with-softroot-1.tar.gz
Description: application/tgz
signature.asc
Description: This is a digitally signed message part.
