# $parts is returned.
}
+# This generates a snapshot device name from a device name.
+# eg. sda -> snap_sda
+# Sets $dname.
+function snap_name {
+ dname=`echo -n snap_"$1" | tr -cs '[:alnum:]' _`
+}
+
#----------------------------------------------------------------------
# Network configuration functions.
# Snapshot the block devices.
for d in $devices_to_send; do
- log snapshotting block device /dev/$d ...
+ snap_name $d
+ log snapshotting block device /dev/$d to $dname ...
- snapshot $d snap_$d
+ snapshot $d $dname
# The block devices are whole disks. Use kpartx to repartition them.
- log running kpartx -a /dev/mapper/snap_$d ...
- kpartx -a /dev/mapper/snap_$d
+ log running kpartx -a /dev/mapper/$dname ...
+ kpartx -a /dev/mapper/$dname
done
# Rescan for LVs.
log mount $root_filesystem as /mnt/root
-if [ -f /dev/mapper/snap_$root_filesystem ]; then
- mount /dev/mapper/snap_$root_filesystem /mnt/root
+snap_name $root_filesystem
+root_filesystem_dname="$dname"
+
+if [ -b /dev/mapper/$root_filesystem_dname ]; then
+ mount /dev/mapper/$root_filesystem_dname /mnt/root
else
mount /dev/$root_filesystem /mnt/root
fi
name="$basename-$rdev.img"
log sending $dev to $name
- sectors=`blockdev --getsize /dev/mapper/snap_$dev`
+ snap_name $dev
+
+ sectors=`blockdev --getsize /dev/mapper/$dname`
gigs=$(($sectors/2/1024/1024))
echo "Sending /dev/$dev (${gigs} GB) to remote machine"
- dd if=/dev/mapper/snap_$dev | gzip --best |
+ dd if=/dev/mapper/$dname | gzip --best |
case "$remote_transport" in
ssh)
ssh -p "$remote_port" "$remote_host" \
# Clean up.
#for d in $devices_to_send; do
-# kpartx -d /dev/mapper/snap_$d
-# drop_snapshot snap_$d
+# snap_name $d
+# kpartx -d /dev/mapper/$dname
+# drop_snapshot $dname
#done
# This file must end with a newline