Ghetto Tech Preview - ghettoVCB-restore.sh - Restoring VM's backed up from ghettoVCB to ESX(i) 3.5, 4.x & 5.x

Ghetto Tech Preview - ghettoVCB-restore.sh - Restoring VM's backed up from ghettoVCB to ESX(i) 3.5, 4.x & 5.x

Table of Contents:

    • Description
    • Requirements
    • Setup
    • Usage
    • Sample Execution
    • Change Log
    • Known Issues

Description:

This script performs a restore of virtual machines backed up using ghettoVCB .  Tasks are performed directly within the service console of the ESX(i)  server involved in the restore process. This is currently a Ghetto Tech  Preview that includes basic restore functionality. Two main use cases  are supported in this release:

1) Restore a VM that contains ALL VMDKs on one datastore

2) Restore a VM that has VMDKs located on multiple datastores

In all cases, restored VMs will have VMDKs that reside on the SAME  datastore chosen for the restore process. Please ensure that there is  sufficient space on the target datastore before attempting a restore  operation. In the near future, restoration of VMs backed up using the  compression feature of ghettoVCB will be implemented.

Features

  • Support for logging output
  • Support for various debugging output
  • Allow spaces in VM(s) backup list (not recommended and not a best practice)
  • Support for restore in the following formats: ZEROEDTHICK (default behavior), 2GB SPARSE, THIN or EAGERZEROEDTHICK
  • Support for ESXi 5.1 NEW!
  • Support changing custom VM name during restore NEW! 

If you have found this script to be useful and would like to contribute back, please click here to donate.

If you have any questions, you may post in the dedicated ghettoVCB VMTN community group.


Requirements:

VMs backed up using ghettoVCB.sh on ESX(i) 3.5, 4.x or 5.x

SSH console access to ESX(i) host


Setup:

1) Download ghettoVCB from github (which includes ghettoVCB-restore) by clicking on the ZIP button at the top and upload to either your ESX or ESXi system (use scp or WinSCP to transfer the file)

2) Extract the contents of the zip file (filename will vary):

# unzip ghettoVCB-master.zip

Archive:  ghettoVCB-master.zip
   creating: ghettoVCB-master/
  inflating: ghettoVCB-master/README
  inflating: ghettoVCB-master/ghettoVCB-restore.sh
  inflating: ghettoVCB-master/ghettoVCB-restore_vm_restore_configuration_template
  inflating: ghettoVCB-master/ghettoVCB-vm_backup_configuration_template
  inflating: ghettoVCB-master/ghettoVCB.conf
  inflating: ghettoVCB-master/ghettoVCB.sh

3) The script is now ready to be used and is located in a directory named ghettoVCB-master

# ls -l

-rw-r--r--    1 root     root           281 Jan  6 03:58 README
-rw-r--r--    1 root     root         16024 Jan  6 03:58 ghettoVCB-restore.sh
-rw-r--r--    1 root     root           309 Jan  6 03:58 ghettoVCB-restore_vm_restore_configuration_template
-rw-r--r--    1 root     root           356 Jan  6 03:58 ghettoVCB-vm_backup_configuration_template
-rw-r--r--    1 root     root           631 Jan  6 03:58 ghettoVCB.conf
-rw-r--r--    1 root     root         49375 Jan  6 03:58 ghettoVCB.sh


Usage:

[root@himalaya ~]# ./ghettoVCB-restore.sh
###############################################################################
#
# ghettoVCB-restore for ESX/ESXi 3.5, 4.x and 5.x
# Author: William Lam
# http://www.virtuallyghetto.com/
# Created: 08/18/2009
# Last modified: 2011_11_19_1
#
###############################################################################

Usage: ./ghettoVCB-restore.sh -c [VM_BACKUP_UP_LIST] -l [LOG_FILE] -d [DRYRUN_DEBUG_INFO]

OPTIONS:
   -c     VM backup list
   -l     File ot output logging
   -d     Dryrun/Debug Info [1|2]

(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

Dryrun/Debug Info (dryrun only)
        ./ghettoVCB-restore.sh -c vms_to_restore -d 1
        ./ghettoVCB-restore.sh -c vms_to_restore -d 2

Standard input for script is a file that contains:

1) Full path to the backed up VM

2) Full restore path

3) Restoration disk format

4) Restored VM Display Name (NEW!)

Reminder: When creating this file on a non-Linux/UNIX system, one may  introduce ^M characters that will cause the script to misbehave. To  ensure that this does not occur, please create the file on the ESX/ESXi  host.

Here is a sample of what the file should look like:

[root@himalaya ~]# cat vms_to_restore
#"<DIRECTORY or .TGZ>;<DATASTORE_TO_RESTORE_TO>;<DISK_FORMAT_TO_RESTORE>;<OPTIONAL_RESTORED_VM_DISPLAY_NAME>"
# 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/mini-local-datastore-2/backups/VCSA-5.1/VCSA-5.1-2012-12-25_01-30-36;/vmfs/volumes/mini-local-datastore-1;3"
"/vmfs/volumes/mini-local-datastore-2/backups/VCSA-5.1/VCSA-5.1-2012-12-25_01-30-36;/vmfs/volumes/mini-local-datastore-1;1;VCSA-RESTORE"

Comments in the input file is acceptable so long as the intended line is preceded by a #. The above sample VM restore file,

vms_to_restore, describes the following backup:

VM to restoreDatastore to restore toVMDK formatRestore VM Name
/vmfs/volumes/mini-local-datastore-2/backups/VCSA-5.1/VCSA-5.1-2012-12-25_01-30-36/vmfs/volumes/mini-local-datastore-1thinVCSA-5.1
/vmfs/volumes/mini-local-datastore-2/backups/VCSA-5.1/VCSA-5.1-2012-12-25_01-30-36/vmfs/volumes/mini-local-datastore-zeroedthickVCSA-RESTORE



Sample Execution:

Perform a dryrun by displaying debug information ( restore will not take place)

Display debug information level 1:

# ./ghettoVCB-restore.sh -c vms_to_restore -d 1

################ DEBUG MODE ##############
Virtual Machine: "VCSA-5.1"
VM_ORIG_VMX: "VCSA-5.1.vmx"
VM_ORG_FOLDER: "VCSA-5.1-2012-12-25_01-30-36"
VM_RESTORE_VMX: "VCSA-5.1.vmx"
VM_RESTORE_FOLDER: "VCSA-5.1"
VMDK_LIST_TO_MODIFY:
scsi0:0.fileName = "VCSA-5.1.vmdk"
scsi0:0.fileName  = "VCSA-5.1-0.vmdk"
scsi0:1.fileName = "VCSA-5.1_1.vmdk"
scsi0:1.fileName  = "VCSA-5.1-1.vmdk"
##########################################


################ DEBUG MODE ##############
Virtual Machine: "VCSA-RESTORE"
VM_ORIG_VMX: "VCSA-5.1.vmx"
VM_ORG_FOLDER: "VCSA-5.1-2012-12-25_01-30-36"
VM_RESTORE_VMX: "VCSA-RESTORE.vmx"
VM_RESTORE_FOLDER: "VCSA-RESTORE"
VMDK_LIST_TO_MODIFY:
scsi0:0.fileName = "VCSA-5.1.vmdk"
scsi0:0.fileName  = "VCSA-RESTORE-0.vmdk"
scsi0:1.fileName = "VCSA-5.1_1.vmdk"
scsi0:1.fileName  = "VCSA-RESTORE-1.vmdk"
##########################################


Start time: Sun Jan 13 16:45:12 UTC 2013
End   time: Sun Jan 13 16:45:14 UTC 2013
Duration  : 2 Seconds

---------------------------------------------------------------------------------------------------------------

Display debug information level 2:

[root@himalaya ~]# ./ghettoVCB-restore.sh -c vms_to_restore -d 2


################## Restoring VM: VCSA-5.1  #####################
==========> DEBUG MODE LEVEL 2 ENABLED <==========
Start time: Sun Jan 13 16:45:35 UTC 2013
Restoring VM from: "/vmfs/volumes/mini-local-datastore-2/backups/VCSA-5.1/VCSA-5.1-2012-12-25_01-30-36"
Restoring VM to Datastore: "/vmfs/volumes/mini-local-datastore-1" using Disk Format: "thin"
Creating VM directory: "/vmfs/volumes/mini-local-datastore-1/VCSA-5.1" ...
Copying "VCSA-5.1.vmx" file ...
Restoring VM's VMDK(s) ...
Updating VMDK entry in "VCSA-5.1.vmx" file ...

SOURCE: "/vmfs/volumes/mini-local-datastore-2/backups/VCSA-5.1/VCSA-5.1-2012-12-25_01-30-36/VCSA-5.1.vmdk"
    ORIGINAL_VMX_LINE: -->scsi0:0.fileName = "VCSA-5.1.vmdk"<--
DESTINATION: "/vmfs/volumes/mini-local-datastore-1/VCSA-5.1/VCSA-5.1-0.vmdk"
    MODIFIED_VMX_LINE: -->scsi0:0.fileName  = "VCSA-5.1-0.vmdk"<--
Updating VMDK entry in "VCSA-5.1.vmx" file ...

SOURCE: "/vmfs/volumes/mini-local-datastore-2/backups/VCSA-5.1/VCSA-5.1-2012-12-25_01-30-36/VCSA-5.1_1.vmdk"
    ORIGINAL_VMX_LINE: -->scsi0:1.fileName = "VCSA-5.1_1.vmdk"<--
DESTINATION: "/vmfs/volumes/mini-local-datastore-1/VCSA-5.1/VCSA-5.1-1.vmdk"
    MODIFIED_VMX_LINE: -->scsi0:1.fileName  = "VCSA-5.1-1.vmdk"<--
Registering VCSA-5.1 ...
End time: Sun Jan 13 16:45:35 UTC 2013
################## Completed restore for VCSA-5.1! #####################

################## Restoring VM: VCSA-RESTORE  #####################
==========> DEBUG MODE LEVEL 2 ENABLED <==========
Start time: Sun Jan 13 16:45:35 UTC 2013
Restoring VM from: "/vmfs/volumes/mini-local-datastore-2/backups/VCSA-5.1/VCSA-5.1-2012-12-25_01-30-36"
Restoring VM to Datastore: "/vmfs/volumes/mini-local-datastore-1" using Disk Format: "zeroedthick"
Creating VM directory: "/vmfs/volumes/mini-local-datastore-1/VCSA-RESTORE" ...
Copying "VCSA-5.1.vmx" file ...
Restoring VM's VMDK(s) ...
Updating VMDK entry in "VCSA-RESTORE.vmx" file ...

SOURCE: "/vmfs/volumes/mini-local-datastore-2/backups/VCSA-5.1/VCSA-5.1-2012-12-25_01-30-36/VCSA-5.1.vmdk"
    ORIGINAL_VMX_LINE: -->scsi0:0.fileName = "VCSA-5.1.vmdk"<--
DESTINATION: "/vmfs/volumes/mini-local-datastore-1/VCSA-RESTORE/VCSA-RESTORE-0.vmdk"
    MODIFIED_VMX_LINE: -->scsi0:0.fileName  = "VCSA-RESTORE-0.vmdk"<--
Updating VMDK entry in "VCSA-RESTORE.vmx" file ...

SOURCE: "/vmfs/volumes/mini-local-datastore-2/backups/VCSA-5.1/VCSA-5.1-2012-12-25_01-30-36/VCSA-5.1_1.vmdk"
    ORIGINAL_VMX_LINE: -->scsi0:1.fileName = "VCSA-5.1_1.vmdk"<--
DESTINATION: "/vmfs/volumes/mini-local-datastore-1/VCSA-RESTORE/VCSA-RESTORE-1.vmdk"
    MODIFIED_VMX_LINE: -->scsi0:1.fileName  = "VCSA-RESTORE-1.vmdk"<--
Registering VCSA-RESTORE ...
End time: Sun Jan 13 16:45:35 UTC 2013
################## Completed restore for VCSA-RESTORE! #####################


Start time: Sun Jan 13 16:45:34 UTC 2013
End   time: Sun Jan 13 16:45:35 UTC 2013
Duration  : 1 Seconds

---------------------------------------------------------------------------------------------------------------

Execute restore with output going to stdout (restore the first two VMs listed from above):

Input file:

# cat vms_to_restore

"/vmfs/volumes/mini-local-datastore-2/backups/VCSA-5.1/VCSA-5.1-2012-12-25_01-30-36;/vmfs/volumes/mini-local-datastore-1;3"
"/vmfs/volumes/mini-local-datastore-2/backups/VCSA-5.1/VCSA-5.1-2012-12-25_01-30-36;/vmfs/volumes/mini-local-datastore-1;1;VCSA-RESTORE"

./ghettoVCB-restore.sh -c vms_to_restore


################## Restoring VM: VCSA-5.1  #####################
Start time: Sun Jan 13 16:46:41 UTC 2013
Restoring VM from: "/vmfs/volumes/mini-local-datastore-2/backups/VCSA-5.1/VCSA-5.1-2012-12-25_01-30-36"
Restoring VM to Datastore: "/vmfs/volumes/mini-local-datastore-1" using Disk Format: "thin"
Creating VM directory: "/vmfs/volumes/mini-local-datastore-1/VCSA-5.1" ...
Copying "VCSA-5.1.vmx" file ...
Restoring VM's VMDK(s) ...
Updating VMDK entry in "VCSA-5.1.vmx" file ...
Destination disk format: VMFS thin-provisioned
Cloning disk '/vmfs/volumes/mini-local-datastore-2/backups/VCSA-5.1/VCSA-5.1-2012-12-25_01-30-36/VCSA-5.1.vmdk'...
Clone: 100% done.
Updating VMDK entry in "VCSA-5.1.vmx" file ...
Destination disk format: VMFS thin-provisioned
Cloning disk '/vmfs/volumes/mini-local-datastore-2/backups/VCSA-5.1/VCSA-5.1-2012-12-25_01-30-36/VCSA-5.1_1.vmdk'...
Clone: 100% done.
Registering VCSA-5.1 ...
34
End time: Sun Jan 13 16:48:51 UTC 2013
################## Completed restore for VCSA-5.1! #####################

################## Restoring VM: VCSA-RESTORE  #####################
Start time: Sun Jan 13 16:48:52 UTC 2013
Restoring VM from: "/vmfs/volumes/mini-local-datastore-2/backups/VCSA-5.1/VCSA-5.1-2012-12-25_01-30-36"
Restoring VM to Datastore: "/vmfs/volumes/mini-local-datastore-1" using Disk Format: "zeroedthick"
Creating VM directory: "/vmfs/volumes/mini-local-datastore-1/VCSA-RESTORE" ...
Copying "VCSA-5.1.vmx" file ...
Restoring VM's VMDK(s) ...
Updating VMDK entry in "VCSA-RESTORE.vmx" file ...
Destination disk format: VMFS zeroedthick
Cloning disk '/vmfs/volumes/mini-local-datastore-2/backups/VCSA-5.1/VCSA-5.1-2012-12-25_01-30-36/VCSA-5.1.vmdk'...
Clone: 100% done.
Updating VMDK entry in "VCSA-RESTORE.vmx" file ...
Failed to clone disk: There is not enough space on the file system for the selected operation (13).
Destination disk format: VMFS zeroedthick
Cloning disk '/vmfs/volumes/mini-local-datastore-2/backups/VCSA-5.1/VCSA-5.1-2012-12-25_01-30-36/VCSA-5.1_1.vmdk'...
Registering VCSA-RESTORE ...
35
End time: Sun Jan 13 16:50:19 UTC 2013
################## Completed restore for VCSA-RESTORE! #####################


Start time: Sun Jan 13 16:46:40 UTC 2013
End   time: Sun Jan 13 16:50:19 UTC 2013
Duration  : 3.65 Minutes


---------------------------------------------------------------------------------------------------------------

Execute restore with output going to log file

/tmp/ghettoVCB-restore.log (restore the last two VMs listed from above):

[root@himalaya ~]# ./ghettoVCB-restore.sh -c vms_to_restore -l /tmp/ghettoVCB-restore.log
Logging output to "/tmp/ghettoVCB-restore.log" ...
Attachments
Comments

nice example, but what is up with the script name? "stupid ass vm with space"

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!

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

vGhetto Script Repository

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

Twitter: @lamw

If you find this information useful, please award points for "correct" or "helpful".

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.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

vGhetto Script Repository

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

Twitter: @lamw

If you find this information useful, please award points for "correct" or "helpful".

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

#""

"/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

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

vGhetto Script Repository

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

Twitter: @lamw

If you find this information useful, please award points for "correct" or "helpful".

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 Smiley Wink You just need to provide the name of your datastore that you're restoring to.

Glad everything works

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

vGhetto Script Repository

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

Twitter: @lamw

If you find this information useful, please award points for "correct" or "helpful".

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 Smiley Wink

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.

First of all great script.

I have successfully backed up my VM's using the script however I was wanting to test the restore function as well to make sure my backups were useful.

When running : "./ghettoVCB-restore.sh -c vmrestore.list" I get the following error message. Same error regardless of whether I'm restoring from a compressed .gz file or not.

/backup # ./ghettoVCB-restore.sh -c vmrestore.list

Restoring VM:

Start time: Wed Nov 25 20:01:19 UTC 2009

Restoring VM from: "/vmfs/volumes/vmbackups/Test Machine"

Restoring VM to Datastore: "/vmfs/volumes/datastore1" using Disk Format: "zeroedthick"

Creating VM directory: "/vmfs/volumes/datastore1/Test Machine" ...

Copying "" file ...

cp: /vmfs/volumes/vmbackups/Test Machine: omitting directory

Restoring VM's VMDK(s) ...

Registering ...

(vmodl.fault.InvalidArgument) {

dynamicType = ,

msg = "A specified parameter was not correct.

"

}

End time: Wed Nov 25 20:01:20 UTC 2009

Completed restore for !

Start time: Wed Nov 25 20:01:19 UTC 2009

End time: Wed Nov 25 20:01:20 UTC 2009

Duration : 1 Seconds

Any Clues...? Thanks.

Can you please re-run the restore using -d 2 which is second level of debugging, remember to always provide debugging information when running into issues/problems and all this is documented within this document Smiley Wink

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

Twitter: @lamw

vGhetto Script Repository

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

I'm looking at your initial output provided and it looks like it was not able to locate the .vmx configuration file and thats probably why its throwing the error because it uses the .vmx to register. Secondly, there is no support for restoring a zipped backup.

Remember that this script is ONLY supported if your back up were taken from ghettoVCB.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

Twitter: @lamw

vGhetto Script Repository

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

Here is the debug level 2 output: Thank you.

/backup # ./ghettoVCB-restore.sh -c vmrestore.list -d 2

Restoring VM:

==========> DEBUG MODE LEVEL 2 ENABLED <==========

Start time: Thu Nov 26 16:28:15 UTC 2009

Restoring VM from: "/vmfs/volumes/vmbackups/Test Machine"

Restoring VM to Datastore: "/vmfs/volumes/datastore1" using Disk Format: "zeroedthick"

Creating VM directory: "/vmfs/volumes/datastore1/Test Machine" ...

Copying "" file ...

Restoring VM's VMDK(s) ...

Registering ...

End time: Thu Nov 26 16:28:15 UTC 2009

Completed restore for !

Start time: Thu Nov 26 16:28:15 UTC 2009

End time: Thu Nov 26 16:28:15 UTC 2009

Duration : 0 Seconds

Take a look at my previous reply .... I don't see the amount of debugging info as I should be. Is there a .vmx file in the directory in which you're trying to restore the VM from?

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

Twitter: @lamw

vGhetto Script Repository

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

Never mind I just figured it out. I feel like a goober. When I was declaring my "restore from" path I was stopping one directory short. I was using /vmfs/volumes/vmbackups/Test Machine when I needed to be using /vmfs/volumes/vmbackups/Test Machine/Test Machine-2009-11-25--1. Thank you for all of your help. Also kudos on the script again.

I have ESXi 4.0. I had to adjust your script to remove every blank line in it. Same thing with the backup script. Strange.

After that it runs fine. I just tested restore and it worked very well. When you start the restored VM you have to choose "i moved it" to the UUID question, else you loose networking (at least on my linux VM).

Great scripts ! Excellent.

Just a quick note:

./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!

I had the same problem some days ago - but i didn't have taken .tgz backups... I had a typo in my restore-path. Seems like "Support for .tgz not supported" is the default msg when the path is not found. Maybe another message would help find the solution?

Greets

Peter

Thanks for the info, I'll take a look into updating the error message.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

Twitter: @lamw

vGhetto Script Repository

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

Thank you for providing backup and restore scripts. I have, however, encountered a problem while trying to perform a restore on the test (not production) VM called WDW1

First, I used ghettoVCB.sh to backup the VM to an external NFS volume (created with Allegro on a Windows machine). The backup created 3 files: WDW1.vmdk (1 KB) , WDW1.vmx (2KB) , WDW1-flat.vmdk (11G)

Next, I used the "Delete from Disk" GUI option in the VMware Infrastructure Console to remove the VM from the ESX host.

When I executed the ghettoVCB-restore.sh script it reported being complete (see below), but I didn't see a re-emergence of the WDW1VM.

One unusual thing I noticed is that the debug says: Creating VM directory: "/vmfs/volumes/datastore2/WDW1", but that directory does not exist after the script completes.

Here is the debug output:

/vmfs/volumes/4acfe3c9-5ec075de-c4c5-000bcd82437d # ./ghettoVCB-restore.sh -c vms_to_restore -d 2

Restoring VM: WDW1

DEBUG MODE LEVEL 2 ENABLED

Start time: Tue Dec 1 13:30:25 UTC 2009

Restoring VM from: "/vmfs/volumes/backup2/WDW1/WDW1-2009-11-30--1"

Restoring VM to Datastore: "/vmfs/volumes/datastore2" using Disk Format: "zeroedthick"

Creating VM directory: "/vmfs/volumes/datastore2/WDW1" ...

Copying "WDW1.vmx" file ...

Restoring VM's VMDK(s) ...

Updating VMDK entry in "WDW1.vmx" file ...

SOURCE: "/vmfs/volumes/backup2/WDW1/WDW1-2009-11-30--1/WDW1.vmdk"

ORIGINAL_VMX_LINE: >scsi0:0.fileName = "WDW1.vmdk"<

DESTINATION: "/vmfs/volumes/datastore2/WDW1/WDW1-0.vmdk"

MODIFIED_VMX_LINE: >scsi0:0.fileName = "WDW1-0.vmdk"<

Registering WDW1 ...

End time: Tue Dec 1 13:30:25 UTC 2009

Completed restore for WDW1!

Start time: Tue Dec 1 13:30:25 UTC 2009

End time: Tue Dec 1 13:30:25 UTC 2009

Duration : 0 Seconds

Thank you,

Greg

Can you paste me your vms_to_restore file and wrap the content in tags

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

Twitter: @lamw

vGhetto Script Repository

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

The following is what happens whenever i trying any execution of the script on the server.

This included the -d 2 diagnostics. no files are generated in the /var/logs dir.

I have included extra outputs to tell you what is where and what is in the vms_to_restore file.

I'd sure like to be able to use this script.

/scripts # ./ghettoVCB-restore.sh -c vms_to_restore

: not found-restore.sh: line 5:

: not found-restore.sh: line 7:

###############################################################################

#

  1. ghettoVCB-restore for ESX/ESXi 3.5u2+ & 4.x+

  2. Author: William Lam

  3. http://www.engineering.ucsb.edu/~duonglt/vmware/

  4. Created: 08/18/2009

  5. Last modified: 08/25/2009

#

###############################################################################

: not found-restore.sh: line 18: echo

Usage: ./ghettoVCB-restore.sh -c -l

: not found-restore.sh: line 20: echo

OPTIONS:

-c VM backup list

-l File ot output logging

: not found-restore.sh: line 24: echo

(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

: not found-restore.sh: line 30: echo

./ghettoVCB-restore.sh: exit: line 31: Illegal number: 1

/scripts # ls /tmp

ipkg.conf sfcb stage vmhsdaemon-0 vms_list vmware-root

/scripts #

###Other information that might be useful.

/scripts # ls -l /vmfs/volumes/datastore1 ; ls -l /vmfs/volumes/Openfiler/ghettovcb/win7/

l----


0 root root 1984 Jan 1 1970 /vmfs/volumes/datastore1 -> 4a2816b8-f83757c1-89fb-001b78bca5f6

-rw-rr 1 nobody nobody 2526342595 Nov 13 21:33 win7-2009-11-13--1.gz

      1. /vmfs/volumes/datastore1 is a sym link here is a listing of that directory.

/scripts # ls /vmfs/volumes/4a2816b8-f83757c1-89fb-001b78bca5f6/

AcronisESXAppliance LSMSK ubuntu-9.04-server-amd64.iso windows2008 server 32bit.iso

LSMDC1 LSMVCS ubuntu-9.04-server-i386.iso winxp-pro.iso

LSMDC2 acronic-rescuedisk.iso win2k3std-64bt-disc1.iso

LSMEX acronis diskdirector.iso win2k3std-64bt-disc2.iso

LSMFS acronis-echo-rescuedisk.iso windows 2008 server stnd 64 bit.iso

###Note that the log file is not being generated.

/scripts # ls /tmp

ipkg.conf sfcb stage vmhsdaemon-0 vms_list vmware-root

/scripts # vmware -v | awk '{print $3}'

4.0.0

      1. a cat of my vms_to_restore file

/scripts # cat /scripts/vms_to_restore

"/vmfs/volumes/Openfiler/ghettovcb/win7/win7-2009-11-13--1.gz;/vmfs/volumes/datastore1;1"

vms_to_restore:

"/vmfs/volumes/backup2/WDW1/WDW1-2009-11-30--1;/vmfs/volumes/datastore2;1"[/code]

Looking at your vms_to_restore, compressed backups are NOT supported in the script. You should have seen an error when trying to execute the script, from the errors I'm seeing it looks like you might have saved/edited the script on a windows system, make sure you download the script and upload directly to ESX(i) host.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

Twitter: @lamw

vGhetto Script Repository

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

The restore file looks to be okay, and based on the logs it looks like it tried to the restore but you mentioned that /vmfs/volumes/datastore2/WDW1 was not created .... ? Is there something wrong with that volume? Can you manually create a directory on that volume? Sounds like there might have been something wrong with that volume.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

Twitter: @lamw

vGhetto Script Repository

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

I am able to create a directory on /vmfs/volumes/datastore2

~ # cd /vmfs/volumes/datastore2

/vmfs/volumes/4acfe3c9-5ec075de-c4c5-000bcd82437d # ls -l

drwxr-xr-x 1 root root 1400 Dec 2 16:44 DEV1

drwxr-xr-x 1 root root 1960 Dec 3 07:12 MAP1

drwxr-xr-x 1 root root 1960 Nov 9 14:30 UBP1

drwxr-xr-x 1 root root 1820 Nov 9 17:19 UDP1

-rw-rr 1 root root 5 Nov 30 19:15 WDW1backup

-rw-rr 1 root root 5 Nov 14 09:41 backup_MAP1

-rw-rr 1 root root 5 Nov 9 18:01 backup_UDP1

-rwxr-xr-x 1 root root 17965 Nov 30 20:50 backup_ghettoVCB.sh

-rwxr-xr-x 1 root root 15279 Dec 1 19:05 ghettoVCB-restore.sh

-rwxr-xr-x 1 root root 17966 Nov 30 20:55 ghettoVCB.sh

-rwxr-xr-x 1 root root 15279 Dec 1 12:17 unmodified_ghettoVCB-restore.sh

-rwxr-xr-x 1 root root 18004 Nov 9 13:25 unmodified_ghettoVCB.sh

-rw-rr 1 root root 10 Nov 9 12:24 vmbackups

-rw-rr 1 root root 76 Dec 2 12:11 vms_to_restore

-rw-rr 1 root root 175 Dec 1 14:32 vms_to_restore_to_backup

/vmfs/volumes/4acfe3c9-5ec075de-c4c5-000bcd82437d # mkdir test

/vmfs/volumes/4acfe3c9-5ec075de-c4c5-000bcd82437d # ls -l

drwxr-xr-x 1 root root 1400 Dec 2 16:44 DEV1

drwxr-xr-x 1 root root 1960 Dec 3 07:12 MAP1

drwxr-xr-x 1 root root 1960 Nov 9 14:30 UBP1

drwxr-xr-x 1 root root 1820 Nov 9 17:19 UDP1

-rw-rr 1 root root 5 Nov 30 19:15 WDW1backup

-rw-rr 1 root root 5 Nov 14 09:41 backup_MAP1

-rw-rr 1 root root 5 Nov 9 18:01 backup_UDP1

-rwxr-xr-x 1 root root 17965 Nov 30 20:50 backup_ghettoVCB.sh

-rwxr-xr-x 1 root root 15279 Dec 1 19:05 ghettoVCB-restore.sh

-rwxr-xr-x 1 root root 17966 Nov 30 20:55 ghettoVCB.sh

drwxr-xr-x 1 root root 280 Dec 3 07:57 test

-rwxr-xr-x 1 root root 15279 Dec 1 12:17 unmodified_ghettoVCB-restore.sh

-rwxr-xr-x 1 root root 18004 Nov 9 13:25 unmodified_ghettoVCB.sh

-rw-rr 1 root root 10 Nov 9 12:24 vmbackups

-rw-rr 1 root root 76 Dec 2 12:11 vms_to_restore

-rw-rr 1 root root 175 Dec 1 14:32 vms_to_restore_to_backup

/vmfs/volumes/4acfe3c9-5ec075de-c4c5-000bcd82437d #

I'm going to try again with a new test VM.

Thank you for your great scripts.

First I ran into the same issue as xerolame[/b] but remembered from a previous version of ghettoVCB that this is the common CRLF problem. So I removed all occurences of \r[/b] using

sed -i.bak 's/\r//g' ghettoVCB-restore.sh

Smiley Wink

But then the next problems occured: I got a few errors stating that it needs an integer expression[/b] in line 141 and a few others. So I changed the conditions to a "working version" from:

if \[ "$" -eq 1 \]; then to if \[ "$" == "1" \]; then

This worked very well for the 10 lines (don't know the exact number) but it actually didn't restore the vmdk-files. The script restored the vmx, modifed the needed parameters and registered the vmx-file, but it did not copy the 2 vmdks. Even though the output stated that it found both.

Now I restored the vmdks on my own using vmkfstools and all works like a charm. I will post the output of the debug level 2 tomorrow, since I'm already at home.

Sorry for the pre[/b] tags, but \[code\][/b] tags didn't work Smiley Sad

afaik, removing the ^M character is not required unless you did something funky during the download such as editing within Widnows editor. I've downloaded both ghettoVCB/ghettoVCB-restore on my system and transferred it to ESX(i) host and executed perfectly fine. As you know, the work around if you get into this problem is to remove via sed or some other method. You should not need to change any of the conditionals so I'm wondering if you're having an issue with specific version of ESX(i) or if something else is going on, definitely see if you can provide debugging logs and that may help me figure out what might be going on.

Can I ask what your environment looks like in terms of the ESX(i) version, VMs, size of VMs, etc.

Also note, the tags used on the VMTN forums is not with 'brackets' but with 'squiggly braces' like

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

Twitter: @lamw

vGhetto Script Repository

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

I don't know what happened to the script. I downloaded it with Firefox on OS X 10.6.2, copied it to the network share and from there to the root's home.

Sorry, forgot to mention my environment:

- 2 ESX 4.0 U1 servers (currently unlicenced/trial, will be upgraded/licensed later this week)

- 8 VMs on the first one, backed up using ghettoVCBg2 using vMA 4.0 U1 onto a Netgear ReadyNAS NFS-share

- the VM in question is a Windows 2003 server with 2 VMDKs (each ~35GB)

I'm currently setting those 2 servers up for a customer and am testing different backup solutions. I wanted to restore the backup of one VM with 2 vmdks (both ~35GB each) to the second vSphere server to find out, if the Exchange server has any problems (lost transactions etc.) with being backed up "hot" (while running on a snapshot). Will have to test tomorrow with a SQL Server.

I will send you the debug log, and the outputs of the script with the line numbers tomorrow morning, since it's currently almost 11pm in germany Smiley Wink And I'm not at work Smiley Happy

Found my mistake with the code tags. I thought, I have to "close" the code using a slash.

I don't have a 4.0u1 system to test with atm, but I imagine it should be exactly the same as 4.0. One thing I noticed you mentioned was you use ghettoVCBg2 to do the backup and the restore script is only supported using ghettoVCB .... I don't believe there is a difference in the way the backups are being stored but that is something to keep in mind.

As you've noted, the logs may hold the key on what's going on. I'll try to spin up an ESX 4.0u1 VM tonight and see if there are any issues with both backup/restore using the scripts.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

Twitter: @lamw

vGhetto Script Repository

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

I have to remove the ^M everytime i download your scripts to my Windows machine - Even if i don't open it. sing Notepad++ to convert to unix and they're gone.

Maybe it's from the squid proxy i have to use here... But even without editing, there are ^M Smiley Wink

Greets

Peter

Hi lamw. Thanks for the quick reply. I don't thing it would make a difference if I used ghettoVCB[/b] or ghettoVCBg2[/b] since the actual backup process is equivalent. Only the "driver" is different (correct me, if I'm wrong)

I grabbed a fresh copy of the script. And here is the config file:

[root@LTH-ESX02 trentis]# cat restore-test
#"<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/STA202I/STA202I-2009-08-18--1;/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage;1"
"/vmfs/volumes/backup/ghettoVCBg2/lth-s06.alpma.de/lth-s06.alpma.de-2009-12-07--1;/vmfs/volumes/storage1;1"

and the contents of the folder

[root@LTH-ESX02 trentis]# la /vmfs/volumes/backup/ghettoVCBg2/lth-s06.alpma.de/lth-s06.alpma.de-2009-12-07--1
total 47G
drwxr-xr-x 1 65534 65534 4.0K Dec  7 20:15 .
drwxr-xr-x 1 65534 65534 4.0K Dec  7 15:42 ..
-rw------- 1 65534 65534 2.2M Dec  7 15:42 lth-s06.alpma.de_1-ctk.vmdk
-rw------- 1 65534 65534  34G Dec  7 15:42 lth-s06.alpma.de_1-flat.vmdk
-rw------- 1 65534 65534  675 Dec  7 15:42 lth-s06.alpma.de_1.vmdk
-rw------- 1 65534 65534 2.2M Dec  7 15:34 lth-s06.alpma.de-ctk.vmdk
-rw------- 1 65534 65534  34G Dec  7 15:34 lth-s06.alpma.de-flat.vmdk
-rw------- 1 65534 65534  671 Dec  7 15:34 lth-s06.alpma.de.vmdk
-rw------- 1 65534 65534 3.8K Dec  7 15:24 lth-s06.alpma.de.vmx

When I run the script without modifications I get the following:

[root@LTH-ESX02 trentis]# la
total 60K
drwx------ 2 trentis trentis 4.0K Dec  8 08:54 .
drwxr-xr-x 3 root    root    4.0K Nov 30 11:00 ..
-rw------- 1 trentis trentis   70 Dec  8 08:47 .bash_history
-rw-r--r-- 1 trentis trentis   33 Nov 30 11:00 .bash_logout
-rw-r--r-- 1 trentis trentis  176 Nov 30 11:00 .bash_profile
-rw-r--r-- 1 trentis trentis  124 Nov 30 11:00 .bashrc
-rwxr-xr-x 1 root    root     15K Dec  8 08:54 ghettoVCB-restore.sh
-rwxr-xr-x 1 root    root     16K Dec  8 08:51 ghettoVCB-restore.sh.bak
-rw-r--r-- 1 root    root     426 Dec  8 08:53 restore-test

[root@LTH-ESX02 trentis]# ./ghettoVCB-restore.sh -c restore-test -d 2
: command not found.sh: line 5:
: command not found.sh: line 7:
'/ghettoVCB-restore.sh: line 8: syntax error near unexpected token `{
'/ghettoVCB-restore.sh: line 8: `printUsage() {

And finally the debug level 2 output:

[root@LTH-ESX02 trentis]# sed -i.bak 's/\r//g' ghettoVCB-restore.sh
[root@LTH-ESX02 trentis]# ./ghettoVCB-restore.sh -c restore-test -d 2
: integer expression expected141: [: 1
: integer expression expected143: [: 1
: integer expression expected145: [: 1
: integer expression expected147: [: 1
################## Restoring VM: lth-s06.alpma.de  #####################
==========> DEBUG MODE LEVEL 2 ENABLED <==========
Start time: Tue Dec  8 08:55:13 CET 2009
Restoring VM from: "/vmfs/volumes/backup/ghettoVCBg2/lth-s06.alpma.de/lth-s06.alpma.de-2009-12-07--1"
Restoring VM to Datastore: "/vmfs/volumes/storage1" using Disk Format: ""
Creating VM directory: "/vmfs/volumes/storage1/lth-s06.alpma.de" ...
Copying "lth-s06.alpma.de.vmx" file ...
Restoring VM's VMDK(s) ...
Updating VMDK entry in "lth-s06.alpma.de.vmx" file ...

SOURCE: "/vmfs/volumes/backup/ghettoVCBg2/lth-s06.alpma.de/lth-s06.alpma.de-2009-12-07--1/lth-s06.alpma.de.vmdk"
        ORIGINAL_VMX_LINE: -->scsi0:0.fileName = "lth-s06.alpma.de.vmdk"<--
DESTINATION: "/vmfs/volumes/storage1/lth-s06.alpma.de/lth-s06.alpma.de-0.vmdk"
        MODIFIED_VMX_LINE: -->scsi0:0.fileName  = "lth-s06.alpma.de-0.vmdk"<--
Updating VMDK entry in "lth-s06.alpma.de.vmx" file ...

SOURCE: "/vmfs/volumes/backup/ghettoVCBg2/lth-s06.alpma.de/lth-s06.alpma.de-2009-12-07--1/lth-s06.alpma.de_1.vmdk"
        ORIGINAL_VMX_LINE: -->scsi0:2.fileName = "lth-s06.alpma.de_1.vmdk"<--
DESTINATION: "/vmfs/volumes/storage1/lth-s06.alpma.de/lth-s06.alpma.de-1.vmdk"
        MODIFIED_VMX_LINE: -->scsi0:2.fileName  = "lth-s06.alpma.de-1.vmdk"<--
Registering lth-s06.alpma.de ...
End time: Tue Dec  8 08:55:13 CET 2009
################## Completed restore for lth-s06.alpma.de! #####################


Start time: Tue Dec  8 08:55:13 CET 2009
End   time: Tue Dec  8 08:55:13 CET 2009
Duration  : 0 Seconds

---------------------------------------------------------------------------------------------------------------

As you can see, there is no output from the actual copy process and the "complains" about the integer expression[/b]

When I also fix those warnings by either adding quotes and the == instead of -eq; or by removing the quotes I get the following debug level 2 output:

[root@LTH-ESX02 trentis]# ./ghettoVCB-restore.sh -c restore-test -d 2
################## Restoring VM: lth-s06.alpma.de  #####################
==========> DEBUG MODE LEVEL 2 ENABLED <==========
Start time: Tue Dec  8 09:11:42 CET 2009
Restoring VM from: "/vmfs/volumes/backup/ghettoVCBg2/lth-s06.alpma.de/lth-s06.alpma.de-2009-12-07--1"
Restoring VM to Datastore: "/vmfs/volumes/storage1" using Disk Format: ""
Creating VM directory: "/vmfs/volumes/storage1/lth-s06.alpma.de" ...
Copying "lth-s06.alpma.de.vmx" file ...
Restoring VM's VMDK(s) ...
Updating VMDK entry in "lth-s06.alpma.de.vmx" file ...

SOURCE: "/vmfs/volumes/backup/ghettoVCBg2/lth-s06.alpma.de/lth-s06.alpma.de-2009-12-07--1/lth-s06.alpma.de.vmdk"
        ORIGINAL_VMX_LINE: -->scsi0:0.fileName = "lth-s06.alpma.de.vmdk"<--
DESTINATION: "/vmfs/volumes/storage1/lth-s06.alpma.de/lth-s06.alpma.de-0.vmdk"
        MODIFIED_VMX_LINE: -->scsi0:0.fileName  = "lth-s06.alpma.de-0.vmdk"<--
Updating VMDK entry in "lth-s06.alpma.de.vmx" file ...

SOURCE: "/vmfs/volumes/backup/ghettoVCBg2/lth-s06.alpma.de/lth-s06.alpma.de-2009-12-07--1/lth-s06.alpma.de_1.vmdk"
        ORIGINAL_VMX_LINE: -->scsi0:2.fileName = "lth-s06.alpma.de_1.vmdk"<--
DESTINATION: "/vmfs/volumes/storage1/lth-s06.alpma.de/lth-s06.alpma.de-1.vmdk"
        MODIFIED_VMX_LINE: -->scsi0:2.fileName  = "lth-s06.alpma.de-1.vmdk"<--
Registering lth-s06.alpma.de ...
End time: Tue Dec  8 09:11:42 CET 2009
################## Completed restore for lth-s06.alpma.de! #####################


Start time: Tue Dec  8 09:11:42 CET 2009
End   time: Tue Dec  8 09:11:42 CET 2009
Duration  : 0 Seconds

---------------------------------------------------------------------------------------------------------------

And without debug, I get some more warnings about integer expressions[/b]:

[root@LTH-ESX02 trentis]# ./ghettoVCB-restore.sh -c restore-test
################## Restoring VM: lth-s06.alpma.de  #####################
Start time: Tue Dec  8 09:12:16 CET 2009
Restoring VM from: "/vmfs/volumes/backup/ghettoVCBg2/lth-s06.alpma.de/lth-s06.alpma.de-2009-12-07--1"
Restoring VM to Datastore: "/vmfs/volumes/storage1" using Disk Format: ""
Creating VM directory: "/vmfs/volumes/storage1/lth-s06.alpma.de" ...
Copying "lth-s06.alpma.de.vmx" file ...
Restoring VM's VMDK(s) ...
Updating VMDK entry in "lth-s06.alpma.de.vmx" file ...
: integer expression expected295: [: 1
: integer expression expected301: [: 1
: integer expression expected303: [: 1
: integer expression expected305: [: 1
Updating VMDK entry in "lth-s06.alpma.de.vmx" file ...
: integer expression expected295: [: 1
: integer expression expected301: [: 1
: integer expression expected303: [: 1
: integer expression expected305: [: 1
Registering lth-s06.alpma.de ...
End time: Tue Dec  8 09:12:17 CET 2009
################## Completed restore for lth-s06.alpma.de! #####################


Start time: Tue Dec  8 09:12:16 CET 2009
End   time: Tue Dec  8 09:12:17 CET 2009
Duration  : 1 Seconds

---------------------------------------------------------------------------------------------------------------

EDIT:[/b]

I forgot to mention that it's Hardware Version 7. Maybe that makes a difference.

I forgot to mention that it's Hardware Version 7. Maybe that makes a difference.

Following up. I had the same result the second time I tried the restore script. The script executed and reported completing with out any error in the debug output, but the directory was never created in the destination datastore and the VM was not restored. Since many other people have had success with this script I am going to have to chalk it up to some unique factor in my method (see RES1.1 in my 3BX blog) or my infrastructure environment. I can still manually restore the vm using the files created with the ghettoVCB back up script - so I'll just be doing things manually. Given the current size of my infrastructure that is fine.

Hello!

Thank youf or your scripts! Great work!

But tell me why do I need a script like this to restore VMs?

Isn't it possible to copy the backuped files to a datastore, register the VM and start it?

Or is the purpose of this restore script only to make the restore process more comfortable?

@ralfortner:

I guess the mainpurpose is making the restore process more comfortable. As you may have seen from my earlier posts, I have some trouble with this script, and so I had to restore them manually.

It is possible to copy the backed up files to a datastore and register the VM, but that is (due to many restrictions for the service console) kind of painfull Smiley Wink

I didn't get more than 5 MB/s and so it takes a long time to recover a 100GB VMDK. Even though my backup was on an iSCSI-Storage connected with GB-LAN and the server's RAID could write at approximately 200MB/s (unbuffered).

@William:

I was wondering if it would be possible to design a restore solution similar to ghettoVCBg2 using vMA and vifp. I should definitely dig into that as soon as I have some spare time left. Maybe this weekend I find a few hours Smiley Wink

I will post back, if I find a solution.

As mentioned already, it's to make the backup/restore as much hands off as possible. I'm not sure about you, but I'm not a fan of click this and click that or type this out manually X amount of times.

Yes you can restore using various means but this has been a request from the community to provide a script to aide in the restore process. You don't have to use the script for the restore as the backup process is not done in such a way that you have to us a restore script from me.

Hopefully that answers your question

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

Twitter: @lamw

vGhetto Script Repository

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

Yes I'm aware of vifs potentially being a transport method though it's slow as dirt ...not sure if I would transfer 50-100+GB using vifs unless you don't mind waiting more than double the amount of time using either ghettoVCB or ghettoVCBg2.

Having said that, it probably isn't too much work to implement a vifs restore OR backup... but I'll leave that as an exercise for the users.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

Twitter: @lamw

vGhetto Script Repository

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

Hi Dear William...

Congrats by yours scripts Smiley Happy

I'm having a bit problem with restore script....

When I run restore with debug 2 I get no erros .. (I think 😛 )

/vmfs/volumes/4b547507-9085fc64-4271-00145efbb24e/SCRIPTS/bkp # ./ghettoVCB-restore.sh -c vms-restore -d 2

                                    1. Restoring VM: 2003-teste #####################

==========> DEBUG MODE LEVEL 2 ENABLED <==========

Start time: Tue Feb 9 09:41:15 UTC 2010

Restoring VM from: "/vmfs/volumes/datastore_bkpvm/MACHINES_BKP/2003-teste/2003-teste-2010-02-08--1"

Restoring VM to Datastore: "/vmfs/volumes/datastore_bkpvm/RESTORE_BKP" using Disk Format: "thin"

Creating VM directory: "/vmfs/volumes/datastore_bkpvm/RESTORE_BKP/2003-teste" ...

Copying "2003-teste.vmx" file ...

Restoring VM's VMDK(s) ...

Updating VMDK entry in "2003-teste.vmx" file ...

SOURCE: "/vmfs/volumes/datastore_bkpvm/MACHINES_BKP/2003-teste/2003-teste-2010-02-08--1/4b704136-57443f3e-d0eb-00145efbb24c/win2003r2.vmdk"

ORIGINAL_VMX_LINE: >scsi0:0.fileName = "/vmfs/volumes/4b704136-57443f3e-d0eb-00145efbb24c/win2003r2.vmdk"<

DESTINATION: "/vmfs/volumes/datastore_bkpvm/RESTORE_BKP/2003-teste/2003-teste-0.vmdk"

MODIFIED_VMX_LINE: >scsi0:0.fileName = "2003-teste-0.vmdk"<

Registering 2003-teste ...

End time: Tue Feb 9 09:41:15 UTC 2010

                                    1. Completed restore for 2003-teste! #####################

Start time: Tue Feb 9 09:41:15 UTC 2010

End time: Tue Feb 9 09:41:15 UTC 2010

Duration : 0 Seconds

-


But when I execute restore (without debug) I get error in DiskLib_Check() ... seee

/vmfs/volumes/4b547507-9085fc64-4271-00145efbb24e/SCRIPTS/bkp # ./ghettoVCB-restore.sh -c vms-restore

                                    1. Restoring VM: 2003-teste #####################

Start time: Tue Feb 9 09:45:12 UTC 2010

Restoring VM from: "/vmfs/volumes/datastore_bkpvm/MACHINES_BKP/2003-teste/2003-teste-2010-02-08--1"

Restoring VM to Datastore: "/vmfs/volumes/datastore_bkpvm/RESTORE_BKP" using Disk Format: "thin"

Creating VM directory: "/vmfs/volumes/datastore_bkpvm/RESTORE_BKP/2003-teste" ...

Copying "2003-teste.vmx" file ...

Restoring VM's VMDK(s) ...

Updating VMDK entry in "2003-teste.vmx" file ...

DiskLib_Check() failed for source disk The system cannot find the file specified (25).

Registering 2003-teste ...

End time: Tue Feb 9 09:45:13 UTC 2010

                                    1. Completed restore for 2003-teste! #####################

Start time: Tue Feb 9 09:45:12 UTC 2010

End time: Tue Feb 9 09:45:13 UTC 2010

Duration : 1 Seconds

-


Have you any idea about solve this !!?

thanks

Carlos

What is the recommended setting (create new or keep) for UUID when restoring a test backup VM ? I choose not to create a new UUID but after the VM came up I had a lot of errors in the event log related to security on the domain.

Thank you in advance

I generally just go with VMware's default when it detects that a VM may have been moved form it's original location and select create. The issues you're seeing should not be related to the UUID generation since this is just an ID for the ESX(i) host to uniquely keep track of each VM. The errors you're seeing is system related, probably due to AD detecting another instance that is slightly different than what it was when originally added to AD.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

Twitter: @lamw

vGhetto Script Repository

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

Thanks for the response. If it is domain security related is there a documented / recomnmended work around for this issue? Rename VM ? Take it off the domain and push it back? So far I have not found a solution. Ideas?

I'm not an expert nor novice in Windows security or AD, perhaps do a search online for the specific event that you're seeing and how you might go about remediating the issue.

Removing it from AD and adding it back in, might be one approach and something you can easily test. What is the exact error you're seeing in the event logs? Is this blocking you from doing something on the restored VM? Are you able to login to the VM using AD credentials?

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

Twitter: @lamw

vGhetto Script Repository

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

Below are the errors in question. As you can see it is very AD / domain security related. This backup test is a 2003 VM Altiris server that connects to another another VM SQL server using domain account credentials.

If I push this test VM off the domain and then add it again how will that affect the powered down production VM when I turn it back on tonight? Could I potentially create a problem or would I just need to do the domain OFF / ON shuffle again? In theory of course Smiley Happy

Event Source: LSASRV

Event Category: SPNEGO (Negotiator)

Event ID: 40960

The attempted logon is invalid. This is either due to a bad username or authentication information.

Event Type: Error

Event Source: NETLOGON

Event Category: None

Event ID: 3210

This computer could not authenticate with...

Event Type: Error

Event Source: Service Control Manager

Event ID: 7038

The EventReceiver service was unable to log on with the currently configured password due to the following error:

The trust relationship between this workstation and the primary domain failed.

Event Type: Error

Event Source: Userenv

Event Category: None

Event ID: 1053

Description:

Windows cannot determine the user or computer name. (Access is denied. ). Group Policy processing aborted.

Yea, I'm not 100% sure but it sounds like you would probably see some funny issues with either your "production" VM or from the AD, since you dropped and re-added and it'll probably affect the existing system since the entry has now been updated. I think the best way to verify this scenario is to spin up a new VM, join it to the domain. Take a backup, power down the original and restore. When restoring try (keep and creatig UUID) and then see if you continue to have the issue. If you still continue to have the issue, then remove the entry from AD, also remove the restore VM from AD via "My Computer" and then reboot and re-add the system into AD. This hopefully would give you a clean restore. Again, I'm not a Windows/AD expert, but this does bring up a good question around restoring systems that were once attached to directory services. I would have guessed that if everything stayed the same, that the system should just work.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

Twitter: @lamw

vGhetto Script Repository

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

So I just did a very quick test to see what results I would see with our AD setup and a WindowsXP system joined to our AD. I took a backup and I did have the VM power down for this, it should work with a live backup as well. I then powered down my original VM and restored the VM to another datastore. I was prompted on whether or not I "moved" or "copied" the VM, I selected "copied". Once the VM was restored, I powered it on and tried to login using domain credentials and it worked like a charm. I looked the event logs and didn't see any errors/warnings, which is a good sign. I then delete the backup and powered on the original VM and I was still able to login to the domain without any issues.

I suspect what you're seeing might be server side configuration which is causing some of the events you're seeing in the logs, not 100% sure. Though it does work

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

Twitter: @lamw

vGhetto Script Repository

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

If I am reading your response correctly you restored your test backup VM to the same hardware it originated from? I was restoring my test backup VM to entirely different hardware. Not the server I imaged it from. Is that what is causing me the issues? Or should a restore to different hardware not be an issue in the VM world?

It technically should not matter, VMs should be hardware independent, one of the benefits of virtualization. We only have 1 physical host, so I had to restore to the same system.

Again, your error is more specific with the security of your AD. I would recommend that you test the various scenarios as I had mentioned in the previous replies and see what the results are, that'll probably be the easiest way to figure out whats going on.

Good luck

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

Twitter: @lamw

vGhetto Script Repository

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

Hi,

first of all I would like to thanks for the nice backup function!

I've backuped to an external NFS Server without any problems,

but I don't know how restore directly from a NFS Server?

Thx in advance

Claus

Version history
Revision #:
1 of 1
Last update:
‎08-23-2009 11:28 PM
Updated by: