initial commit of file from CVS for smeserver-rsync-backup2disk on Sat Sep 7 19:58:58 AEST 2024
This commit is contained in:
57
root/etc/e-smith/events/actions/rsync-backup
Executable file
57
root/etc/e-smith/events/actions/rsync-backup
Executable file
@@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
|
||||
STATUS=$(/sbin/e-smith/config getprop rsync status)
|
||||
if [ "$STATUS" != 'enabled' ]
|
||||
then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# variables
|
||||
STIME=$(/bin/date)
|
||||
MOUNT=$(/sbin/e-smith/config getprop rsync Mount)
|
||||
ID=$(/sbin/e-smith/config get SystemName).$(/sbin/e-smith/config get DomainName)
|
||||
RSYNC="/usr/bin/rsync"
|
||||
OPTIONS="-aur --delete --stats --force --files-from=/etc/rsync.include --exclude-from=/etc/rsync.exclude"
|
||||
|
||||
# fix if /etc/smbpasswd from rsync.include is missing
|
||||
if [ ! -e /etc/smbpasswd ]
|
||||
then
|
||||
/bin/touch /etc/smbpasswd
|
||||
fi
|
||||
|
||||
# release & mount destination
|
||||
/bin/umount $MOUNT >/dev/null 2>&1
|
||||
|
||||
/bin/echo "Connecting to $MOUNT"
|
||||
/bin/mount $MOUNT || exit 1
|
||||
|
||||
# check for valid ext3
|
||||
if [ ! -d $MOUNT/lost+found ]
|
||||
then
|
||||
/bin/echo "$MOUNT does not appear to be ext3 format!"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# create destination dirs
|
||||
/bin/mkdir -p $MOUNT/$ID/rsync || exit 3
|
||||
|
||||
# execute pre-backup event
|
||||
/bin/echo "Executing pre-backup event"
|
||||
/sbin/e-smith/signal-event pre-backup || exit 4
|
||||
|
||||
# perform rsync backup
|
||||
/bin/echo "Performing rsync to $MOUNT/$ID/rsync"
|
||||
$RSYNC $OPTIONS / $MOUNT/$ID/rsync || exit 5
|
||||
|
||||
# execute post-backup event
|
||||
/bin/echo "Executing post-backup event"
|
||||
/sbin/e-smith/signal-event post-backup || exit 6
|
||||
|
||||
# dismount
|
||||
/bin/echo "Dismounting $MOUNT"
|
||||
/bin/umount -l $MOUNT &
|
||||
|
||||
FTIME=$(/bin/date)
|
||||
/bin/echo ""
|
||||
/bin/echo "$STIME - backup started"
|
||||
/bin/echo "$FTIME - backup finished"
|
43
root/etc/e-smith/events/actions/rsync-restore
Executable file
43
root/etc/e-smith/events/actions/rsync-restore
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/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
|
Reference in New Issue
Block a user