This is an old revision of the document!


VMware tips

Fixing time-management in vm-instances on VMware

Install the VMware tools in the guest os, then in the .vmx-file set the following parameters to TRUE:

  • tools.syncTime - sync periodically
  • time.synchronize.continue - sync after snapshot
  • time.synchronize.restore - sync after reverting to a snapshot
  • time.synchronize.resume.disk - sync after resume
  • time.synchronize.shrink - sync after defragmenting a virtual disk
Do NOT run any other timekeepers in the guest operating system! (like the W32Time service on windows and the NTP daemon on UNIX systems). Read this pdf (written by VMware) for more details and background information.

Backing up virtual machines on VMware Server 2.0

Because WMware's backup of running virtual machines is still in experimental stage, you have to shut down the virtual machines and then copy files from the datastore. That is - if you you want to avoid using that experimental feature.

You can create a user on a virtual machine and grant permission to shut down via sudo:

  • sudo adduser username admin enables user username to run sudo
  • add username hostname = NOPASSWD: /sbin/shutdown to /etc/sudoers
  • Create a script, that will shut down virtual machines, check with ping after one minute if it is really shut down and then copy VM's files from datastore to TARGET location and after finishing that, power virtual machine back on. Of course you run it on your VMware Server host - where you have the datastore.

Here is an example of the script. You will have to modify at least usernames and paths, maybe more, but it will give you an idea of how it can be done.

#!/bin/bash
#
# Backup virtual machines
#
# In file /home/user/vm_hostnames define hosts of virtual machines (as they appear in VMware Server).
# DNS records for the same names must exist too!
#
TARGET=/mnt/backup
#
for VM in `cat /home/user/vm_hostnames`
do
	ssh username@${VM} sudo /sbin/shutdown -h now
	sleep 60
	ping -c 2 ${VM}
	TARGET_PATH=${TARGET}/${VM}.`/bin/date +%Y%m%d`
	mkdir $TARGET_PATH
	if [ $? -eq 1 ]
		then
			cp /vm/Virtual\ Machines/${VM}/* ${TARGET_PATH}/
			/usr/local/vmware-server/bin/vmrun -T server -h https://VM_HOST_IP:8333/sdk -u vmuser -p vmpass start "[standard] ${VM}/${VM}.vmx"
		else
			echo Host $VM not shut down yet! >> /home/user/vm_backup.err
	fi
done

vmuser and vmpass are username and password you use to login to VMware Server console. VM_HOST_IP is the IP of your VMware Server host. The file vm_hostnames in the script is a list of hostnames of virtual machines you wish to back up.

vmware.1243204502.txt.gz · Last modified: 2009/06/01 16:11 (external edit)
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 ipv6 ready