--- /dev/null
+#!/bin/bash
+
+# One must supply the disk name as an argument to this script
+[ $# == 1 ] || exit 1
+
+scriptsdir=$(dirname $0)
+
+export PATH=$scriptsdir:/bin:/usr/bin:/sbin:/usr/sbin
+
+# source the default configuration
+. config.sh
+
+# source the system specific configuration
+[ -f /etc/lsbackups.conf ] && . /etc/lsbackups.conf
+
+isoimage="$imagedir/$1.iso"
+isomountdir="$isoimage.mnt"
+
+echo "-> Checking for available disk space on $imagedir"
+available=$(df $imagedir | awk '{print$4}' | grep -E "[0-9]+")
+required=$((imagesizemb*1024))
+[ $required -gt $available ] && err "Not enough space for the backup image on $imagedir"
+
+echo "-> Creating directories"
+mkdir --mode=700 -p $datadir $imagedir $isomountdir $tmpdir
+if [ $? != 0 ]; then
+ test -d $isomountdir && rm -rf $isomountdir
+ err "Unable to create the following directories:
+ $datadir $imagedir $isomountdir $tmpdir"
+fi
+
+echo "-> Creating the iso image in $isoimage"
+dd of=$isoimage bs=1M count=0 seek=$imagesizemb
+
+[ $? != 0 ] && err "dd failed to create $isoimage"
+
+mke2fs -b $blocksize -F $isoimage
+if [ $? != 0 ]; then
+ rm -rf $isomountdir $isoimage
+ err "Unable to create the iso image: $isoimage"
+fi
+
+e2label $isoimage $today
+if [ $? != 0 ]; then
+ rm -rf $isomountdir $isoimage
+ err "Unable to label the iso image: $isoimage"
+fi
+
+echo "-> Mounting the iso image"
+mount -t ext2 -o loop $isoimage $isomountdir
+if [ $? != 0 ]; then
+ rm -rf $isomountdir $isoimage
+ err "Unable to mount the iso image: $isoimage -> $isomountdir"
+fi
+
+echo "-> Querying backupdb for files originally placed on disk $1"
+cat $backupdb | files-from-date.sh $1 > $1.filelist
+
+echo "-> Repacking backup image for disk $1"
+cat $1.filelist | rsync -W -H -S -l -p -t -g -o -0 --files-from=- --stats --progress / $isomountdir
+umount $isomountdir
+rm $1.filelist
+md5sum $isoimage | awk '{print$1}' > $isoimage.md5sum
+
+
+
+
+
+
+
+