Some time the simple scripts are the best. Disaster Recovery (DR) backups do not have to be made every day. At some places I’ve worked we made DR backups as little as one a year.
DR backups contain everything. You copy the entire envirement so you can buy new hardware and restore the operation of the needed services as quickly as posible without installing from scratch. Backups on tape are great but how can you restore the data if you don’t have a tape server with the right OS and software in place ready to do the restore? VMware makes this eazy because it uses files as disks and you can make point in time snapshots.
I use a SATA toster to mount disks via eSata and copy my system with this script. These run on the ESX(i) server. The backups are copied to disk space mounted via NFS. To uses these you run the buildlist script and write the output to a file and then run the output-ed file as a script. The only part of this you should have to change is the DESTDIR variable in the vmdrbackup script. It should be the directory your NFS backup is mounted at.
buildlist > list
list
Here are the scripts
vmlist
/bin/vim-cmd vmsvc/getallvms | grep -v Vmid
vmsnapshot
/bin/vim-cmd vmsvc/snapshot.create $1 DR-BACKUP DR-BACKUP
vmremovesnapshot
/bin/vim-cmd vmsvc/snapshot.remove $1
buildlist
./vmlist | awk ‘{print “./vmsnapshot “$1”nsleep 60n./vmdrbackup Datastore1 “$4”n./vmremovesnapshot “$1}’
bmdrbackup
# vmdrbackup – VMware Daster Recovery Backup
# vmdrbackup DataStore VMDIR/VM.vmx
#DIR=`echo $2 | awk -F ‘/’ ‘{print $1}’`
DESTDIR=“/vmfs/volumes/VM.Backups/$DIR”# Backup old copy
if [ -e $DESTDIR ]; then
echo “Saving Old DR folder.”
mv $DESTDIR $DESTDIR.save
fi# Create new directory
if [ ! -e $DESTDIR ]; then
echo “Create new folder ($DIR) for DR backup.”
/bin/mkdir /vmfs/volumes/VM.Backups/$DIR
fi# Copy each .vmdk file to the Destination
for file in `ls /vmfs/volumes/$1/$DIR/*.vmdk | grep -v flat | grep -v delta`
do
dest=`echo $file | awk -F ‘/’ ‘{print $6}’`
/sbin/vmkfstools -i $file /vmfs/volumes/VM.Backups/$DIR/$dest
doneecho “Coping Virtual Config file ($DIR.vmx).”
cp /vmfs/volumes/$1/$DIR/*.vmx /vmfs/volumes/VM.Backups/$DIR
Enjoy