linux - VMware virtual machines wont resume from the command line -
i'm running vmware workstation on ubuntu 10.10. have series of virtual machines clone every week.
i've written bash script cycles through each of virtual machines, softly suspends it, clones it, , attempts resume it.
the problem is, vm's not resume, have manually resume them. i'm trying figure out how can modify script i've written ensure vms resume. i've included script , sample of generated logfile showing error message.
#!/bin/bash ##author: william cooper ##date: 2/15/2011 ## purpose: perform full backups of virtual machines ## running under vmware workstation ## script won't run if /nas directory doesn't exist ## /nas directory mounted buffalo terastation ## check /etc/fstab if mountpoint broken backupdest="/nas" ## no need modify host=`hostname` datefile=`/bin/date +%g%m%d` ## run command find list of vm names: ## name of vm, no path , no .vmx vmlist=`vmrun list | grep '/' | cut -d'/' -f3 | cut -d'.' -f1` ## initialize counter variable used cycle through vms in vmarray variable counter=1 ## run command find list of vm names , store them in array: ## include full pathnames vmarray=( `vmrun list | grep '/'` ) ################################################################# ## functions ## ## notify starting time of backup in log ## function startscript { echo echo "----------------------------------------------------" echo "start - ${vm}" echo "host: ${host}" echo "date: `date`" echo } ## ## suspend vm ## function suspendvm { ## suspend vm echo "attempting softly suspend "${vm}" . . ." vmrun suspend ${vmarray[${counter}]} soft echo "${vm} suspended on `date`" echo } ## ## backup vm ## function dobackup { ## check see if correct backup directory exists. if [ ! -d ${backupdest}/${vm} ]; echo "${backupdest}/${vm} not exist, creating . . ." mkdir "${backupdest}/${vm}" echo fi ## backup vm (clone) echo "backup of "${vm}" began: `date`" echo "backup ${backupdest}/${vm}/backup/${datefile} . . ." mkdir ${backupdest}/${vm}/backup/${datefile} vmrun clone ${vmarray[${counter}]} ${backupdest}/${vm}/backup/${datefile}/${vm}.vmx full echo "backup of "${vm}" ended: `date`" echo } ## ## start vm ## function dostart { ## resume vms running [--type gui|sdl|vrdp|headless] echo "attempting resume "${vm}" . . ." vmrun start ${vmarray[${counter}]} echo "${vm} resumed on `date`" echo } ## ## notify finishing time of backup in log ## function finishscript { echo "finish - ${vm}" echo "host: ${host}" echo "date: `date`" echo "----------------------------------------------------" echo } ################################################################# ## script vm in ${vmlist} sleep 1 ## startscrip executes logging startscript ## suspend vm performs soft suspend suspendvm sleep 3 ## backup performs vm clone dobackup sleep 3 ## start vm performs start vm dostart sleep 3 ## finishscript executes logging finishscript ## increment counter counter=${counter}+1 done | tee "${backupdest}/logs/vmclone_${datefile}.log" ## script ################################################################# exit
an example of generated logfile each vm shown below.
---------------------------------------------------- start - vmname host: servername date: sat feb 19 12:30:29 cst 2011 attempting softly suspend vmname . . . vmname suspended on sat feb 19 12:30:44 cst 2011 backup of vmname began: sat feb 19 12:30:47 cst 2011 backup /nas/vmname/backup/20110219 . . . backup of vmname ended: sat feb 19 12:43:16 cst 2011 attempting resume vmname . . . error: cannot launch ui because no display server present in current environment vmname resumed on sat feb 19 12:43:20 cst 2011 finish - vmname host: servername date: sat feb 19 12:43:23 cst 2011 ----------------------------------------------------
error: cannot launch ui because no display server present in current environment
you use nogui paramater start command, e.g:
vmrun start yourmachine.vmx nogui
Comments
Post a Comment