#!/bin/bash
# masterback2 - (C) 09/22/03 - JPmicrosystems
# Backup Windoze system to big portable drive
# One file system at a time in compressed partimage format

#This script does the actual work once invoked by su in masterback02 (to get access to everything)

# First, make sure the portable drive is mounted
df | grep 'hdb1' > /tmp/backuptmp
if [ -s /tmp/backuptmp ]
then
  echo /mnt/portable already mounted
else
  mount /dev/hdb1 /mnt/portable
  status=$?
  if [ $status != 0 ]
  then
    echo "Couldn't mount hdb1 = status was $status"
    exit $status
  fi
fi

echo "Creating Partition image of Windows C Drive"
/usr/sbin/partimage -z1 -o -d -m -b -f3 save /dev/hda1 /mnt/portable/cdrive
status=$?
if [ $status -eq 0 ]
then
  echo
  echo "Backup of Windows C Drive successfully completed"
  echo
else
  echo "Backup of Windows C Drive FAILED with status $status"
  exit $status
fi

echo "Creating Partition image of Windows D Drive"
/usr/sbin/partimage -z1 -o -d -m -b -f3 save /dev/hda5 /mnt/portable/ddrive
status=$?
if [ $status -eq 0 ]
then
  echo
  echo "Backup of Windows D Drive successfully completed"
  echo
else
  echo "Backup of Windows D Drive FAILED with status $status"
  exit $status
fi

exit 0
