Sie sind auf Seite 1von 8

Ghetto Tech Preview - ghettoVCB-restore.

sh -
Restoring VM's backed up from ghettoVCB to
ESX(i) 3.5 and 4.0+

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

Requirements:
VMs backed up using ghettoVCB.sh on ESX(i) 3.5 or 4.0
SSH console access to ESX/ESXi 3.5 or 4.0 host

Generated by Clearspace on 2010-05-11-07:00


1
Ghetto Tech Preview - ghettoVCB-restore.sh - Restoring VM's backed up from ghettoVCB to ESX(i) 3.5 and 4.0+

Setup:
1) Download ghettoVCB-restore.tar.gz and upload to either your ESX or ESXi system (use scp or WinSCP to
transfer the file)

2) Extract the contents of the tarball

[root@himalaya ~]# tar -zxvf


ghettoVCB-restore.tar.gz
ghettoVCB-restore/
ghettoVCB-restore/ghettoVCB-restore.sh
ghettoVCB-restore/vms_to_restore_sample.txt

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

[root@himalaya
ghettoVCB-restore]# ls -l
total 20
-rwxr-xr-x 1 root root 15279 May 10 18:41 ghettoVCB-restore.sh
-rw-r--r-- 1 root root 309 May 10 18:41 vms_to_restore_sample.txt

Usage:
[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

Generated by Clearspace on 2010-05-11-07:00


2
Ghetto Tech Preview - ghettoVCB-restore.sh - Restoring VM's backed up from ghettoVCB to ESX(i) 3.5 and 4.0+

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
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>"
# 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/volume
"/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/VCAP/VCAP-2009-08-20--1;/vmfs/volume
"/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/sideswipe/sideswipe-2009-08-20--1;/v
"/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;

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 restore Datastore to restore to VMDK format

/vmfs/volumes/dlgCore-NFS- /vmfs/volumes/himalaya-local- zeroedthick


bigboi.VM-Backups/ SATA.RE4-GP:Storage
WILLIAM_BACKUPS/VCAP/VCAP-
2009-08-20--1

/vmfs/volumes/dlgCore-NFS- /vmfs/volumes/himalaya-local- zeroedthick


bigboi.VM-Backups/ SATA.RE4-GP:Storage
WILLIAM_BACKUPS/sideswipe/
sideswipe-2009-08-20--1

/vmfs/volumes/dlgCore-NFS- /vmfs/volumes/himalaya-local- 2gbsparse


bigboi.VM-Backups/ SATA.RE4-GP:Storage
WILLIAM_BACKUPS/stupid ass
vm with spaces/stupid ass vm with
spaces-2009-08-20--1

/vmfs/volumes/dlgCore-NFS- /vmfs/volumes/himalaya-local- thin


bigboi.VM-Backups/ SATA.RE4-GP:Storage

Generated by Clearspace on 2010-05-11-07:00


3
Ghetto Tech Preview - ghettoVCB-restore.sh - Restoring VM's backed up from ghettoVCB to ESX(i) 3.5 and 4.0+

WILLIAM_BACKUPS/vMA-resize/
vMA-resize-2009-08-23--1

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

Input file:
[root@himalaya ~]# cat
vms_to_restore
"/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/VCAP/VCAP-2009-08-20--1;/vmfs/volume
"/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/sideswipe/sideswipe-2009-08-20--1;/v

[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

Generated by Clearspace on 2010-05-11-07:00


4
Ghetto Tech Preview - ghettoVCB-restore.sh - Restoring VM's backed up from ghettoVCB to ESX(i) 3.5 and 4.0+

'/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/sideswipe/sideswipe-2009-08-20--1/si
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/4a
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/4a
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/si
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

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

Execute restore with output going to log file /tmp/ghettoVCB-restore.log (restore the last two VMs listed from
above):

Input file:
[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;

[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

Display debug information level 1:


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

Generated by Clearspace on 2010-05-11-07:00


5
Ghetto Tech Preview - ghettoVCB-restore.sh - Restoring VM's backed up from ghettoVCB to ESX(i) 3.5 and 4.0+

################ 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

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

Display debug information level 2:


[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

Generated by Clearspace on 2010-05-11-07:00


6
Ghetto Tech Preview - ghettoVCB-restore.sh - Restoring VM's backed up from ghettoVCB to ESX(i) 3.5 and 4.0+

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

Generated by Clearspace on 2010-05-11-07:00


7
Ghetto Tech Preview - ghettoVCB-restore.sh - Restoring VM's backed up from ghettoVCB to ESX(i) 3.5 and 4.0+

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

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

Change Log:
05/10/2010

Tarred up ghettoVCB-restore.sh script and sample input file per user request

Known Issues:

Generated by Clearspace on 2010-05-11-07:00


8

Das könnte Ihnen auch gefallen