Command-line backup for VMWare Fusion Virtual Machines

If you have a bunch of VMWare Fusion virtual machines running, you can suspend them programmatically using vmrun and rsync them to a mounted volume. Then, with the copy completed, you can resume the virtual machines.

#!/bin/bash

BACKUPDIR=/Volumes/Backup/VMs

/Library/Application\ Support/VMware\ Fusion/vmrun list | tail -n +2 | while read VM
do
  echo "Suspending $VM"
  time /Library/Application\ Support/VMware\ Fusion/vmrun -T fusion suspend "$VM"
  echo "Suspended $VM"
  
  DIR=`dirname "$VM"`
  echo "Rsyncing $DIR"
  rsync -av "$DIR" "$BACKUPDIR"
 
  echo "Resuming $VM"
  time /Library/Application\ Support/VMware\ Fusion/vmrun -T fusion start "$VM"
  echo "Resumed $VM"
done

Note: this hung on Windows VMs until I updated VMWare Tools to the latest version on the guest. The above is currently working on Fusion 3.1 for RHEL5 and Windows 2008 R2 Server guests.

[ Submitted by John on Tue, 2010-06-08 14:28. | | ]

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question tests your humanity.