chmod +x ghettoVCB-restore.sh
[root@himalaya ~]# ./ghettoVCB-restore.sh
###############################################################################
#
# ghettoVCB-restore for ESX/ESXi 3.5u2+ & 4.x+
# Author: William Lam
# http://www.engineering.ucsb.edu/~duonglt/vmware/
# Created: 08/18/2009
# Last modified: 08/25/2009
#
###############################################################################
Usage: ./ghettoVCB-restore.sh -c [VM_BACKUP_UP_LIST] -l [LOG_FILE]
OPTIONS:
-c VM backup list
-l File ot output logging
(e.g.)
Output will go to stdout
./ghettoVCB-restore.sh -c vms_to_restore
Output will log to /tmp/ghettoVCB-restore.log
./ghettoVCB-restore.sh -c vms_to_restore -l /tmp/ghettoVCB-restore.log
[root@himalaya ~]# cat vms_to_restore
#"<DIRECTORY or .TGZ>;<DATASTORE_TO_RESTORE_TO>;<DISK_FORMAT_TO_RESTORE>"
# DISK_FORMATS
# 1 = zeroedthick
# 2 = 2gbsparse
# 3 = thin
# 4 = eagerzeroedthick
# e.g.
# "/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/VCAP/VCAP-2009-08-18--1;/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage;1"
"/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/VCAP/VCAP-2009-08-20--1;/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage;1"
"/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/sideswipe/sideswipe-2009-08-20--1;/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage;1"
"/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/stupid ass vm with spaces/stupid ass vm with spaces-2009-08-20--1;/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage;2"
"/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/vMA-resize/vMA-resize-2009-08-23--1;/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage;3"
| VM to restore | Datastore to restore to | VMDK format |
| /vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/VCAP/VCAP-2009-08-20--1 | /vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage | zeroedthick |
| /vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/sideswipe/sideswipe-2009-08-20--1 | /vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage | zeroedthick |
| /vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/stupid ass vm with spaces/stupid ass vm with spaces-2009-08-20--1 | /vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage | 2gbsparse |
| /vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/vMA-resize/vMA-resize-2009-08-23--1 | /vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage | thin |
[root@himalaya ~]# cat vms_to_restore
"/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/VCAP/VCAP-2009-08-20--1;/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage;1"
"/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/sideswipe/sideswipe-2009-08-20--1;/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage;1"
[root@himalaya ~]# ./ghettoVCB-restore.sh -c vms_to_restore
################## Restoring VM: VCAP #####################
Start time: Sun Aug 23 22:31:26 PDT 2009
Restoring VM from: "/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/VCAP/VCAP-2009-08-20--1"
Restoring VM to Datastore: "/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage" using Disk Format: "zeroedthick"
Creating VM directory: "/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage/VCAP" ...
Copying "VCAP.vmx" file ...
Restoring VM's VMDK(s) ...
Updating VMDK entry in "VCAP.vmx" file ...
Destination disk format: VMFS zeroedthick
Cloning disk '/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/VCAP/VCAP-2009-08-20--1/VCAP.vmdk'...
Clone: 100% done.
Registering VCAP ...
End time: Sun Aug 23 22:32:32 PDT 2009
################## Completed restore for VCAP! #####################
################## Restoring VM: sideswipe #####################
Start time: Sun Aug 23 22:32:32 PDT 2009
Restoring VM from: "/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/sideswipe/sideswipe-2009-08-20--1"
Restoring VM to Datastore: "/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage" using Disk Format: "zeroedthick"
Creating VM directory: "/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage/sideswipe" ...
Copying "sideswipe.vmx" file ...
Restoring VM's VMDK(s) ...
Updating VMDK entry in "sideswipe.vmx" file ...
Destination disk format: VMFS zeroedthick
Cloning disk '/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/sideswipe/sideswipe-2009-08-20--1/sideswipe.vmdk'...
Clone: 100% done.
Updating VMDK entry in "sideswipe.vmx" file ...
Destination disk format: VMFS zeroedthick
Cloning disk '/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/sideswipe/sideswipe-2009-08-20--1/4a31aece-e34d675a-72cf-003048d9586a/sideswipe.vmdk'...
Clone: 100% done.
Updating VMDK entry in "sideswipe.vmx" file ...
Destination disk format: VMFS zeroedthick
Cloning disk '/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/sideswipe/sideswipe-2009-08-20--1/4a31aece-e34d675a-72cf-003048d9586a/sideswipe_1.vmdk'...
Clone: 100% done.
Updating VMDK entry in "sideswipe.vmx" file ...
Destination disk format: VMFS zeroedthick
Cloning disk '/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/sideswipe/sideswipe-2009-08-20--1/sideswipe_1.vmdk'...
Clone: 100% done.
Registering sideswipe ...
End time: Sun Aug 23 22:34:46 PDT 2009
################## Completed restore for sideswipe! #####################
Start time: Sun Aug 23 22:31:26 PDT 2009
End time: Sun Aug 23 22:34:46 PDT 2009
Duration : 3.33 Minutes
---------------------------------------------------------------------------------------------------------------
[root@himalaya ~]# cat vms_to_restore
"/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/stupid ass vm with spaces/stupid ass vm with spaces-2009-08-20--1;/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage;2"
"/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/vMA-resize/vMA-resize-2009-08-23--1;/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage;3"
[root@himalaya ~]# ./ghettoVCB-restore.sh -c vms_to_restore -l /tmp/ghettoVCB-restore.log
Logging output to "/tmp/ghettoVCB-restore.log" ...
cat /tmp/ghettoVCB-restore.log
[root@himalaya ~]# ./ghettoVCB-restore.sh -c vms_to_restore -d 1
################ DEBUG MODE ##############
Virtual Machine: "VCAP"
VM_VMX: "VCAP.vmx"
VM_ORG_FOLDER: "VCAP-2009-08-20--1"
VM_FOLDER_NAME: "VCAP"
VMDK_LIST_TO_MODIFY:
scsi0:0.fileName = "VCAP.vmdk"
scsi0:0.fileName = "VCAP-0.vmdk"
##########################################
################ DEBUG MODE ##############
Virtual Machine: "sideswipe"
VM_VMX: "sideswipe.vmx"
VM_ORG_FOLDER: "sideswipe-2009-08-20--1"
VM_FOLDER_NAME: "sideswipe"
VMDK_LIST_TO_MODIFY:
scsi0:0.fileName = "sideswipe.vmdk"
scsi0:0.fileName = "sideswipe-0.vmdk"
scsi0:1.fileName = "/vmfs/volumes/4a31aece-e34d675a-72cf-003048d9586a/sideswipe/sideswipe.vmdk"
scsi0:1.fileName = "sideswipe-1.vmdk"
scsi1:8.fileName = "/vmfs/volumes/4a31aece-e34d675a-72cf-003048d9586a/sideswipe/sideswipe_1.vmdk"
scsi1:8.fileName = "sideswipe-2.vmdk"
scsi3:12.fileName = "sideswipe_1.vmdk"
scsi3:12.fileName = "sideswipe-3.vmdk"
##########################################
Start time: Sun Aug 23 23:04:49 PDT 2009
End time: Sun Aug 23 23:04:49 PDT 2009
Duration : 0 Seconds
---------------------------------------------------------------------------------------------------------------
[root@himalaya ~]# ./ghettoVCB-restore.sh -c vms_to_restore -d 2
################## Restoring VM: stupid ass vm with spaces #####################
==========> DEBUG MODE LEVEL 2 ENABLED <==========
Start time: Sun Aug 23 23:05:11 PDT 2009
Restoring VM from: "/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/stupid ass vm with spaces/stupid ass vm with spaces-2009-08-20--1"
Restoring VM to Datastore: "/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage" using Disk Format: "2gbsparse"
Creating VM directory: "/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage/stupid ass vm with spaces" ...
Copying "stupid ass vm with spaces.vmx" file ...
Restoring VM's VMDK(s) ...
Updating VMDK entry in "stupid ass vm with spaces.vmx" file ...
SOURCE: "/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/stupid ass vm with spaces/stupid ass vm with spaces-2009-08-20--1/stupid ass vm with spaces.vmdk"
ORIGINAL_VMX_LINE: -->scsi0:0.fileName = "stupid ass vm with spaces.vmdk"<--
DESTIONATION: "/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage/stupid ass vm with spaces/stupid ass vm with spaces-0.vmdk"
MODIFIED_VMX_LINE: -->scsi0:0.fileName = "stupid ass vm with spaces-0.vmdk"<--
Updating VMDK entry in "stupid ass vm with spaces.vmx" file ...
SOURCE: "/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/stupid ass vm with spaces/stupid ass vm with spaces-2009-08-20--1/4a31aece-e34d675a-72cf-003048d9586a/stupid ass vm with spaces.vmdk"
ORIGINAL_VMX_LINE: -->scsi0:1.fileName = "/vmfs/volumes/4a31aece-e34d675a-72cf-003048d9586a/stupid ass vm with spaces/stupid ass vm with spaces.vmdk"<--
DESTIONATION: "/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage/stupid ass vm with spaces/stupid ass vm with spaces-1.vmdk"
MODIFIED_VMX_LINE: -->scsi0:1.fileName = "stupid ass vm with spaces-1.vmdk"<--
Updating VMDK entry in "stupid ass vm with spaces.vmx" file ...
SOURCE: "/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/stupid ass vm with spaces/stupid ass vm with spaces-2009-08-20--1/4a31aece-e34d675a-72cf-003048d9586a/stupid ass vm with spaces_1.vmdk"
ORIGINAL_VMX_LINE: -->scsi0:2.fileName = "/vmfs/volumes/4a31aece-e34d675a-72cf-003048d9586a/stupid ass vm with spaces/stupid ass vm with spaces_1.vmdk"<--
DESTIONATION: "/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage/stupid ass vm with spaces/stupid ass vm with spaces-2.vmdk"
MODIFIED_VMX_LINE: -->scsi0:2.fileName = "stupid ass vm with spaces-2.vmdk"<--
Registering stupid ass vm with spaces ...
End time: Sun Aug 23 23:05:11 PDT 2009
################## Completed restore for stupid ass vm with spaces! #####################
################## Restoring VM: vMA-resize #####################
==========> DEBUG MODE LEVEL 2 ENABLED <==========
Start time: Sun Aug 23 23:05:11 PDT 2009
Restoring VM from: "/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/vMA-resize/vMA-resize-2009-08-23--1"
Restoring VM to Datastore: "/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage" using Disk Format: "thin"
Creating VM directory: "/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage/vMA-resize" ...
Copying "vMA-resize.vmx" file ...
Restoring VM's VMDK(s) ...
Updating VMDK entry in "vMA-resize.vmx" file ...
SOURCE: "/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/vMA-resize/vMA-resize-2009-08-23--1/vMA-resize.vmdk"
ORIGINAL_VMX_LINE: -->scsi0:0.fileName = "vMA-resize.vmdk"<--
DESTIONATION: "/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage/vMA-resize/vMA-resize-0.vmdk"
MODIFIED_VMX_LINE: -->scsi0:0.fileName = "vMA-resize-0.vmdk"<--
Registering vMA-resize ...
End time: Sun Aug 23 23:05:11 PDT 2009
################## Completed restore for vMA-resize! #####################
Start time: Sun Aug 23 23:05:11 PDT 2009
End time: Sun Aug 23 23:05:11 PDT 2009
Duration : 0 Seconds
---------------------------------------------------------------------------------------------------------------
It works. I wiped my VM using VI Client (a bit scary), then I used this script to restore a previous backup. After a while it automatically popped up in the VI client.
Very nice. Thanks a lot.
Awesome to hear!
when I run the restore script I get the following....complains about support for .tgz ???
~ # ./ghettoVCB-restore.sh -c vms_to_restore
Support for .tgz not supported - "/vmfs/volumes/backup/OCSSE_DR/OCSSE_DR-2009-10-01" will not be backed up!
Start time: Thu Oct 1 11:37:31 UTC 2009
End time: Thu Oct 1 11:37:31 UTC 2009
Duration : 0 Seconds
As noted in this document, compression restore is not supported yet.
I've tried walking away so I could look at this from a fresh mind, but I'm still getting a path problem on restore.
Could I get some input on maybe some syntax problems with this?? I'm really sure about the path. I've tried the aliased (as shown) and actual (with all the letters/numbers) for the final directory where the datastore resides.
I've run it from the root directory and in the datastore directory just for giggles. No luck.
restore.txt
#"<DIRECTORY or .TGZ>;<DATASTORE_TO_RESTORE_TO>;<DISK_FORMAT_TO_RESTORE>"
"/vmfs/volumes/macpro/vm/IBMvfusion;/vmfs/volumes/datastore1:datastore1;1"
Output
~ # ./ghettoVCB-restore.sh -c restore.txt
ERROR: Unable to verify datastore locateion: "/vmfs/volumes/datastore1:datastore1"! Ensure this exists
Thanks for looking
Brian
Remember to note that this script will ONLY work with backups taken with ghettoVCB.sh ... I only bring this up to ensure you're able to use the script and secondly, the format of your restore configuration doesn't match up from the sample template provided.
The first param /vmfs/volumes/macpro/vm/IBMvfusion should look something like /vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/VCAP/VCAP-2009-08-18--1 where it points to the directory of a specific VM backup, not the root directory of the VM backups but a specific backup.
The second param /vmfs/volumes/datastore1:datastore1 is the datastore to restore to, I don't know if this is correct or a typo? Did you mean to say _/vmfs/volumes/datastore1_?
The third param 1 should just be the disk format and that looks fine to me.
Pleae double check your input and make sure /vmfs/volumes/datastore1:datastore1 does exists
Found the clue in this:
"Did you mean to say _/vmfs/volumes/datastore1_?"
I took verbatim what was in the original restore text like this:
"/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/VCAP/VCAP-2009-08-18--1;/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage;1"
"/vmfs/volumes/macpro/vm/IBMvfusion;/vmfs/volumes/datastore1:datastore1;1"
but this worked:
"/vmfs/volumes/macpro/vm/IBMvfusion;/vmfs/volumes/datastore1;1"
I'm assuming somewhere along the line the ":Storage" part worked at one time?? Or I was using it incorrectly.
Thanks for your help and VERY SOLID blogging/reply posts in all the ESX forums.
Brian
The example I gave was for our development environment and the datastore I was testing this with had the following display name: "/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage", ":Storage" is not some string that needs to be appended
You just need to provide the name of your datastore that you're restoring to.
Glad everything works
banthorpe,
I also got that message about "Support for .tgz not supported..." even though I had not chosen any file that was tgz'd.
What I found was that I had the wrong case (Macpro instead of macpro) on one of my nfs datastores. I was using essentially a wrong path. The script couldn't find the directory and halted. Just took some squinting on my part to see my error.
I added my own comment to the script in case I forget in the future too ![]()
Brian
I cannot even run this script.
The script fails to create a log file even.
It is spouting off errors in the actual script involving lines 30 / 31
http://pastebin.com/m15e0794c has more information. I tried to throw in some diagnostic info as well.
nice example, but what is up with the script name? "stupid ass vm with space"