#!/bin/bash
# masterback1 - (C) 09/22/03 - JPmicrosystems - GNU GPL
# Backup whole system to big portable drive
# One file system at a time in compressed dump format

#This script does the actual work once invoked by su in masterback0 (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

filesys=( hda6 hda7 hda9 )
target=(  boot root home )

for ((i=0; i<3; i++));
do
  echo
  echo "Starting Backup of /dev/${filesys[$i]} to /mnt/portable/${target[$i]}"
  echo
  /sbin/dump 0uMBzf 1048576 /mnt/portable/${target[$i]} /dev/${filesys[$i]}
  status="$?"
  if [ $status -eq 0 ]
  then
    echo
    echo "Backup of /dev/${filesys[i]} successfully completed"
    echo
  else
    echo "Backup of /dev/${filesys[i]} FAILED with status $status"
    exit $status
  fi
done

/home/bigbird/bin/masterback2
status=$?

exit $status
