0

I have a script that is run to backup a server via Rsync, after that script is run I want the server to reboot.

My script is run as root from the Crontab at 3am in the morning.

#!/bin/bash

HOST="email"

RSYNC_OPTS="-a -v -v --progress --stats --delete"
RSYNC_DEST="10.0.0.10::$HOST"

BACKUP_LIST="/etc /home /root"

TIMESTAMP="/timestamp-bkup-start.chk"
TIMESTAMP2="/timestamp-bkup-stop.chk"

touch $TIMESTAMP

rsync $RSYNC_OPTS $TIMESTAMP $RSYNC_DEST

for BACKUP_ITEM in $BACKUP_LIST;
  do
    rsync $RSYNC_OPTS $BACKUP_ITEM $RSYNC_DEST
  done

/etc/init.d/zimbra stop
sleep 60s

rsync $RSYNC_OPTS /opt $RSYNC_DEST

touch $TIMESTAMP2
rsync $RSYNC_OPTS $TIMESTAMP2 $RSYNC_DEST

echo `date +%Y%m%d%H%M` >> /var/log/reset
reboot

# $# shows number of args passed
# $1 to access first variable

#if [ $# -eq 1 ]; then
#        if [ $1 = "withreboot" ]; then
#                echo "rebooting...";
#               echo `date +%Y%m%d%H%M` >> /var/log/reset
#               /sbin/reboot
#        fi
#fi

I have tried using init 6 rather then reboot. I have tried /sbin/reboot.

I also have another basic script that just echos to the reset log and runs reboot without issue. It is just with the script above the server wont restart.

If anyone has any theories that would be great as I have run out of idea.

Thanks,

Jon

1

Is it perhaps that a call to reboot goes via shutdown (i.e. shutdown -r) does reboot --force operate any differently? (it does what is says on the tin..)

  • 1
    You may have to put the full path. – d-_-b Jun 3 '10 at 0:27
  • This is not really a great solution at all. It causes the box to reboot WITHOUT dismounting partitions or stopping any services. Anyone else got any good ideas? – Littlejon Jun 5 '10 at 10:38
  • Unmount the partitions first? ;) – DrDanielSwan Jun 7 '10 at 8:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.