On Sunday 13 January 2008 08:24:09 Sheldon Hearn wrote:
> Results tarball (and modified run script) attached.

Oops, that's not the modified version (which performs bind mounts for 
both chroot and softroot).

Ciao,
Sheldon.
#!/bin/sh -x

DO_CHROOT=0

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 /

binds="$BACKUP_PREFIX /etc/fsvs /var/spool/fsvs $BINDS"
for bind in $binds; do
        mount --bind $bind $SNAP_MOUNT/$bind
done

# 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
        chroot $SNAP_MOUNT fsvs commit $DEBUG -m 'Automatic backup'
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 \
                               $SNAP_MOUNT
fi
set -e

for bind in $binds; do
        umount $SNAP_MOUNT/$bind
done

# 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

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to