I have a backup script I run on an UBUNTU 12.04 server box that is supposed to shut the virtual machines computer down, execute a tar backup, then reboot the virtual machine when backup is complete. I wrote it to run two backups in the script. However, the script executes nicely but the virtual machine does not restart on its own. I have to manually restart it. The vmware.log logs dont show anything that triggers a solution for me. Any ideas? i am posting my script below........
#!/bin/bash
#script to backup virtual machines
#written by trainerbee August 20, 2013
#for use on Ubuntu 12.04 kernel
echo "Nightly VM Backup to NAS"
echo "script written by trainerbee"
NOW="$(date)"
printf "Current date and time %s\n" "$NOW"
echo "About to begin the nightly backup, please wait..."
now="$(date +'%m-%d-%Y')"
echo "--------------Date stamp after midnight------------------------"
FILE="server2bkup-$now.tar"
FILE2="SERVER2BACK2-$now.tar"
# rest of script
echo "we have two VMs to backup"
echo "shutting down the 1st guest VM, then sleeping for two mins please wait..."
vmrun -T ws stop /var/lib/vmware/Virtual\ Machines/Windows\ Svr\ 2k8\ x64-3/Windows\ Svr\ 2k8\ x64-3.vmx soft
sleep 120
echo "Lets begin backup of 1st VM, sleeping for 15 mins"
tar cvf /home/user/netgear/$FILE /var/lib/vmware/Virtual\ Machines/Windows\ Svr\ 2k8\ x64-3/ --exclude *.log
sleep 900
echo "finished backing up 1st VM..."
echo "we can backup 2nd VM now, begin the backup, and sleeping for 3.5 hours"
tar cvf /home/user/netgear/$FILE2 /var/lib/vmware/Virtual\ Machines/Windows\ Svr\ 2k8\ x64/ --exclude *.log
sleep 12600
#could the problem be the time here? we are looking for 3.5hours.
echo "backup should be completed by now...
echo "though we backed up two, we only restart one guest machine..and wait 3 minutes"
vmrun -T ws start /var/lib/vmware/Virtual\ Machines/Windows\ Svr\ 2k8\ x64-3/Windows\ Svr\ 2k8\ x64-3.vmx nogui
sleep 180
echo "guest should be rebooted by now"
cd /home/user/netgear
echo "************LIST OF DIRECTORIES************"
ls -lh
echo "************END OF DIRECTORIES*************"
echo "$now backup is complete"