#!/bin/sh

ROOT=`pwd`
echo "#### Creating backup"
echo "#### ROOT is $ROOT"

for f in / /var /usr /usr/local /export/input /home
do
	echo "##   Filesystem $f"
	name=`echo $f | tr / _`


	cd ${ROOT}$f

	tar \
	--create \
	--sparse \
	--atime-preserve \
	--preserve \
	--file=- \
	--read-full-records \
	--one-file-system \
	--same-owner --numeric-owner \
	--gzip \
	--totals \
	.  > ${ROOT}/export/output/dvd/${name}.tgz

done

f=/export/output
echo "##   Filesystem $f"
cd ${ROOT}$f
name=`echo $f | tr / _`

    tar \
    --create \
    --sparse \
    --atime-preserve \
    --preserve \
    --file=- \
    --read-full-records \
    --one-file-system \
    --same-owner --numeric-owner \
    --gzip \
    --totals \
    ./dvd/boot ./dvd/config ./dvd/docs ./tmp ./frames \
                              > ${ROOT}/export/output/dvd/${name}.tgz



cd ${ROOT}/export/output/dvd

mkisofs -o ../bootdvd.iso \
-b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat \
-no-emul-boot -boot-load-size 4 -boot-info-table \
-rational-rock -full-iso9660-filenames -allow-leading-dots \
-joliet -allow-leading-dots -omit-version-number \
.


