發新話題
打印

[轉貼]VMware esxi 備份還原ghettoVCB-restore.sh 設定說明

[轉貼]VMware esxi 備份還原ghettoVCB-restore.sh 設定說明

http://blog.faq-book.com/?p=4269

一、 介紹

此腳本主要是用來還原虛擬機的備份。也屬於ghettoVCB中的一部份。

在這個腳本中支持兩個主要的用途

1. 恢復一個備份的VM包含所有在這個資料儲存區的VMDKs

2. 恢復多個儲存於資料儲存區的備份的VM,包含所有在這個資料儲存區的VMDKs

 

使用腳本時先注意,該還原目地有足夠的空間,然後在嘗試還原。以避免問題的產生。支持的還原格式:zeroedthick(default behavior)2gbsparsethineagerzeroedthick

 

使用需求:

需使用ghettoVCB.sh備份

ESX(i) 3.545.x

SSH連線訪問的到該台主機

 

詳細內容可參考VMware官網–ghettoVCB-restore.sh

 

二、 ghettoVCB-restore.sh 設定說明

首先,先下載ghettoVCB-restore,然後上傳到要還原的該台主機上,若不知怎麼上傳的人可以參考此篇的前半部

 

1. 解壓縮上傳的資料

解壓縮後會看到ghettoVCB-restore.sh該檔。此檔案就是用來將備份的VM還原使用。


~ # tar -zxvf lamw-ghettoVCB-518cef7.tar.gz

tar: warning: skipping header 'g'

lamw-ghettoVCB-518cef7/

lamw-ghettoVCB-518cef7/README

lamw-ghettoVCB-518cef7/ghettoVCB-restore.sh

lamw-ghettoVCB-518cef7/ghettoVCB-restore_vm_restore_configuration_template

lamw-ghettoVCB-518cef7/ghettoVCB-vm_backup_configuration_template

lamw-ghettoVCB-518cef7/ghettoVCB.conf

lamw-ghettoVCB-518cef7/ghettoVCB.sh

~ # cd lamw-ghettoVCB-518cef7

~ # ls                                              ghettoVCB-vm_backup_configuration_template           README

ghettoVCB-restore.sh                                 ghettoVCB.conf

ghettoVCB-restore_vm_restore_configuration_template  ghettoVCB.sh

 

2. 查看ghettoVCB-restore.sh使用到的參數


~ # ./ghettoVCB-restore.sh

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

#

# ghettoVCB-restore for ESX/ESXi 3.5, 4.x+ and 5.0

# Author: William Lam

# http://www.virtuallyghetto.com/

# Documentation: http://communities.vmware.com/docs/DOC-8760

# 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  (指定LOG所要儲存的路徑)

   -d     Dryrun/Debug Info [1|2] (可用來測試或是Debug還原看是否有誤)

 

(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

  

3. 建立還原使用的list

要建立此list主要是讓在還原的時後比較方便。然而在這一份list中有幾點要注意的。

(1) VM備份檔所在地的完整路徑。

(2) 恢復後的VM要存放的完整路徑

(3) 設定恢復硬碟的格式 (格式不懂的可以參考VMware ESX(i)虛擬磁碟格式介紹)

格式代號    格式名稱

      1 = zeroedthick

      2 = 2gbsparse

      3 = thin

      4 = eagerzeroedthick

(4) list請使用在ESXESX(i)主機上。請勿用在non-Linux/UNIX系統上,避免特殊符號影響導致腳本錯誤。

 

以下是list的範例,還請之後依照各人而設定。

list裡可以直接把硬碟的格式代號也加入,方便日後查詢。不過要記得#才不會影響到腳本。


~ # vi vms_to_restore

# DISK_FORMATS

# 1 = zeroedthick

# 2 = 2gbsparse

# 3 = thin

# 4 = eagerzeroedthick

# e.g.

 

"/vmfs/volumes/datastore1/backup/backup/test/test-2012-01-11_23-48-35;/vmfs/volumes/datastore1;4"                                         

#"VM備份檔所在地的完整路徑;恢復後的VM要存放的完整路徑;恢復硬碟的格式 "

#在這邊要注意一下是「;」而不是「:

 

4. 測試Dryrun/Debug

設定好vms_to_restore後,可以使用Dryrun/Debug來測試看看腳本和vms_to_restore是否有問題。


Dryrun/Debug Info [1|2]

 

Dryrun:

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

 

Debug:

~ # ./ghettoVCB-restore.sh -c vms_to_restore -d 2

 

5. 還原備份

要還原備份時請使用參數「-c」然後接vms_to_restore也就是剛剛所建的list


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

################## Restoring VM: test  #####################

Start time: Wed Jan 11 23:52:11 UTC 2012

Restoring VM from: "/vmfs/volumes/datastore1/backup/backup/test/test-2012-01-11_23-48-35"

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

Creating VM directory: "/vmfs/volumes/datastore1/test-2012-01-11_23-48-35" …

Copying "test.vmx" file …

Restoring VM's VMDK(s) …

Updating VMDK entry in "test.vmx" file …

Destination disk format: VMFS eagerzeroedthick

Cloning disk '/vmfs/volumes/datastore1/backup/backup/test/test-2012-01-11_23-48-35/test.vmdk'…

Clone: 100% done.

Registering test …

23

End time: Wed Jan 11 23:52:29 UTC 2012

################## Completed restore for test! #####################

 

 

Start time: Wed Jan 11 23:52:11 UTC 2012

End   time: Wed Jan 11 23:52:29 UTC 2012

Duration  : 18 Seconds

 

還原完成後開啟VMware vSphere Client會看到剛剛所還原回去的VM已經自己掛上了。

接下來就可以開啟VM後測試看試否有問題。

 

6. 備份log設定

如果要設定log的話,會建議把log存在不會因重開機,而刪檔的地方吧。

若只是要測試的話就放在/tmp下就可以了。


#還原備份並設定LOG存放處

~ # ./ghettoVCB-restore.sh -c vms_to_restore -l /tmp/ghettoVCB-restore.log

Logging output to "/tmp/ghettoVCB-restore.log" …

Destination disk format: VMFS eagerzeroedthick

Cloning disk '/vmfs/volumes/datastore1/backup/backup/test/test-2012-01-11_23-48-35/test.vmdk'…

Clone: 100% done.

24

 

#備份完成,到tmp查看log

~ # cat /tmp/ghettoVCB-restore.log

Destination disk format: VMFS eagerzeroedthick

Cloning disk '/vmfs/volumes/datastore1/backup/backup/test/test-2012-01-11_23-48-35/test.vmdk'…

Clone: 100% done.

Registering test …

End time: Thu Jan 12 00:05:47 UTC 2012

################## Completed restore for test! #####################

 

 

Start time: Thu Jan 12 00:05:30 UTC 2012

End   time: Thu Jan 12 00:05:47 UTC 2012

Duration  : 17 Seconds

 

到這邊備份還原的部份就ok

TOP

發新話題