smeserver-rsync-backup2disk/root/etc/e-smith/events/actions/rsync-restore

44 lines
1.2 KiB
Plaintext
Raw Permalink Normal View History

#!/bin/sh
STATUS=$(/sbin/e-smith/config getprop rsync status)
if [ "$STATUS" != 'enabled' ]
then
exit 0
fi
# variables
MOUNT=$(/sbin/e-smith/config getprop rsync Mount)
ID=$(/sbin/e-smith/config get SystemName).$(/sbin/e-smith/config get DomainName)
# set config
/bin/echo "Enabling CopyFromDisk configuration"
/sbin/e-smith/db configuration setprop backup Program CopyFromDisk status enabled || exit 1
# release & mount destination
/bin/umount $MOUNT >/dev/null 2>&1
/bin/echo "Connecting to $MOUNT"
/bin/mount $MOUNT || exit 2
# check for valid backup
if [ ! -d $MOUNT/$ID/rsync ]
then
/bin/echo "$MOUNT/$ID/rsync does not exist!"
exit 3
fi
# execute pre-restore event
/bin/echo "Executing pre-restore event"
/sbin/e-smith/signal-event pre-restore || exit 4
# perform restore
/bin/echo "Performing restore from $MOUNT/$ID/rsync"
/bin/echo "Please be patient as this may take an extended time to complete"
/sbin/e-smith/signal-event restore-tape $MOUNT/$ID/rsync
/bin/echo "Restore complete"
# execute post-upgrade ; reboot events
/bin/echo "Executing post-upgrade & reboot events"
/sbin/e-smith/signal-event post-upgrade || exit 5
/sbin/e-smith/signal-event reboot