前提

  • オンラインでバックアップ
  • PCIパススルーを設定している仮想マシンはオフラインでしか取れない。

やり方

 バックアップ用スクリプトの使い方説明(英語)
 https://github.com/lamw/ghettoVCB


  1. 以下のサイトからバックアップ用スクリプトをダウンロードする
     バックアップスクリプト(ghettoVCB.sh)
     https://github.com/lamw/ghettoVCB/archive/master.zip

  2. ESXiから見えるバックアップ先のメディアを用意する
      SATAに接続したHDD、iSCSI、NFSなど

  3. 解凍&展開
    # cd /vmfs/volumes/datastore1/~
    # unzip ghettoVCB-master.zip~
    # mv ghettoVCB-master ghettoVCB~
    # cd ghettoVCB~

  4. 設定ファイル編集
    # vi ghettoVCB.conf
    VM_BACKUP_VOLUME=/vmfs/volumes/ESXI_BACKUP/DAILY/ghettoVCB  #バックアップ保存先
    VM_BACKUP_ROTATION_COUNT=3                                  #バックアップは3世代~

  5. バックアップ対象の仮想マシン名を記述
    # vi backup_vmlist.txt
    WEB
    MAIL

  6. オンラインバックアップの実行
    # ./ghettoVCB.sh -f ./backup_vmlist.txt -g ./ghettoVCB.conf
    Logging output to "/tmp/ghettoVCB-2014-09-17_16-12-19-274597.log" ...
    2014-09-17 16:12:19 -- info: ============================== ghettoVCB LOG START ==============================
    
    2014-09-17 16:12:19 -- debug: Succesfully acquired lock directory - /tmp/ghettoVCB.work
    
    2014-09-17 16:12:19 -- debug: HOST VERSION: VMware ESXi 5.5.0 build-1623387
    2014-09-17 16:12:19 -- debug: HOST LEVEL: VMware ESXi 5.5.0 Update 1
    2014-09-17 16:12:19 -- debug: HOSTNAME: esxi.hanzou.jp
    
    2014-09-17 16:12:19 -- info: CONFIG - USING GLOBAL GHETTOVCB CONFIGURATION FILE = ./ghettoVCB.conf
    2014-09-17 16:12:19 -- info: CONFIG - VERSION = 2013_26_11_2
    2014-09-17 16:12:19 -- info: CONFIG - GHETTOVCB_PID = 274597
    2014-09-17 16:12:19 -- info: CONFIG - VM_BACKUP_VOLUME = /vmfs/volumes/ESXI_BACKUP/DAILY/ghettoVCB
    2014-09-17 16:12:19 -- info: CONFIG - VM_BACKUP_ROTATION_COUNT = 3
    2014-09-17 16:12:19 -- info: CONFIG - VM_BACKUP_DIR_NAMING_CONVENTION = 2014-09-18_01-12-19
    2014-09-17 16:12:19 -- info: CONFIG - DISK_BACKUP_FORMAT = thin
    2014-09-17 16:12:19 -- info: CONFIG - POWER_VM_DOWN_BEFORE_BACKUP = 0
    2014-09-17 16:12:20 -- info: CONFIG - ENABLE_HARD_POWER_OFF = 0
    2014-09-17 16:12:20 -- info: CONFIG - ITER_TO_WAIT_SHUTDOWN = 3
    2014-09-17 16:12:20 -- info: CONFIG - POWER_DOWN_TIMEOUT = 5
    2014-09-17 16:12:20 -- info: CONFIG - SNAPSHOT_TIMEOUT = 15
    2014-09-17 16:12:20 -- info: CONFIG - LOG_LEVEL = debug
    2014-09-17 16:12:20 -- info: CONFIG - BACKUP_LOG_OUTPUT = /tmp/ghettoVCB-2014-09-17_16-12-19-274597.log
    2014-09-17 16:12:20 -- info: CONFIG - ENABLE_COMPRESSION = 0
    2014-09-17 16:12:20 -- info: CONFIG - VM_SNAPSHOT_MEMORY = 0
    2014-09-17 16:12:20 -- info: CONFIG - VM_SNAPSHOT_QUIESCE = 0
    2014-09-17 16:12:20 -- info: CONFIG - ALLOW_VMS_WITH_SNAPSHOTS_TO_BE_BACKEDUP = 0
    2014-09-17 16:12:20 -- info: CONFIG - VMDK_FILES_TO_BACKUP = all
    2014-09-17 16:12:20 -- info: CONFIG - VM_SHUTDOWN_ORDER =
    2014-09-17 16:12:20 -- info: CONFIG - VM_STARTUP_ORDER =
    2014-09-17 16:12:20 -- info: CONFIG - RSYNC_LINK = 0
    2014-09-17 16:12:20 -- info: CONFIG - EMAIL_LOG = 0
    2014-09-17 16:12:20 -- info:
    2014-09-17 16:12:23 -- debug: Storage Information before backup:
    2014-09-17 16:12:23 -- debug: SRC_DATASTORE: ESXI_DATA
    2014-09-17 16:12:23 -- debug: SRC_DATASTORE_CAPACITY: 63488.0
    2047.8 GB
    2014-09-17 16:12:23 -- debug: SRC_DATASTORE_FREE: 1316.3 GB
    2014-09-17 16:12:23 -- debug: SRC_DATASTORE_BLOCKSIZE: 1
    2014-09-17 16:12:23 -- debug: SRC_DATASTORE_MAX_FILE_SIZE: 256 GB
    2014-09-17 16:12:23 -- debug:
    2014-09-17 16:12:23 -- debug: DST_DATASTORE: ESXI_BACKUP
    2014-09-17 16:12:23 -- debug: DST_DATASTORE_CAPACITY: 16221.8
    1833.4 GB
    2014-09-17 16:12:23 -- debug: DST_DATASTORE_FREE: 709.7 GB
    2014-09-17 16:12:23 -- debug: DST_DATASTORE_BLOCKSIZE: NA
    2014-09-17 16:12:23 -- debug: DST_DATASTORE_MAX_FILE_SIZE: NA
    2014-09-17 16:12:23 -- debug:
    2014-09-17 16:12:24 -- debug: getVMDKs() - WEB-0.vmdk###16:
    2014-09-17 16:12:25 -- info: Initiate backup for WEB
    2014-09-17 16:12:25 -- info: Creating Snapshot "ghettoVCB-snapshot-2014-09-17" for WEB
    /bin/vim-cmd vmsvc/snapshot.create 133 ghettoVCB-snapshot-2014-09-17 ghettoVCB-snapshot-2014-09-17 0 0
    2014-09-17 16:12:27 -- debug: Waiting for snapshot "ghettoVCB-snapshot-2014-09-17" to be created
    2014-09-17 16:12:27 -- debug: Snapshot timeout set to: 900 seconds
    2014-09-17 16:12:27 -- debug: findVMDK() - Searching for VMDK: "WEB-0.vmdk" to backup
    2014-09-17 16:12:27 -- debug: /sbin/vmkfstools -i "/vmfs/volumes/ESXI_DATA/WEB/WEB-0.vmdk" -a "lsilogic" -d "thin" "/vmfs/volumes/ESXI_BACKUP/DAILY/ghettoVCB/WEB/WEB-2014-09-18_01-12-19/WEB-0.vmdk"
    Destination disk format: VMFS thin-provisioned
    Cloning disk '/vmfs/volumes/ESXI_DATA/WEB/WEB-0.vmdk'...
    Clone: 100% done.
    /bin/vim-cmd vmsvc/snapshot.remove 133 1
    2014-09-17 16:17:45 -- info: Removing snapshot from WEB ...
    2014-09-17 16:17:46 -- debug: Removing /vmfs/volumes/ESXI_BACKUP/DAILY/ghettoVCB/WEB/WEB-2014-09-16_21-32-38
    2014-09-17 16:17:46 -- info: Backup Duration: 5.35 Minutes
    2014-09-17 16:17:46 -- info: Successfully completed backup for WEB!
    
    2014-09-17 16:17:49 -- debug: Storage Information after backup:
    2014-09-17 16:17:49 -- debug: SRC_DATASTORE: ESXI_DATA
    2014-09-17 16:17:49 -- debug: SRC_DATASTORE_CAPACITY: 63488.0
    2047.8 GB
    2014-09-17 16:17:49 -- debug: SRC_DATASTORE_FREE: 1316.3 GB
    2014-09-17 16:17:49 -- debug: SRC_DATASTORE_BLOCKSIZE: 1
    2014-09-17 16:17:49 -- debug: SRC_DATASTORE_MAX_FILE_SIZE: 256 GB
    2014-09-17 16:17:49 -- debug:
    2014-09-17 16:17:49 -- debug: DST_DATASTORE: ESXI_BACKUP
    2014-09-17 16:17:49 -- debug: DST_DATASTORE_CAPACITY: 16221.8
    1833.4 GB
    2014-09-17 16:17:49 -- debug: DST_DATASTORE_FREE: 709.7 GB
    2014-09-17 16:17:49 -- debug: DST_DATASTORE_BLOCKSIZE: NA
    2014-09-17 16:17:49 -- debug: DST_DATASTORE_MAX_FILE_SIZE: NA
    2014-09-17 16:17:49 -- debug:
    2014-09-17 16:17:51 -- debug: Storage Information before backup:
    2014-09-17 16:17:51 -- debug: SRC_DATASTORE: ESXI_DATA
    2014-09-17 16:17:51 -- debug: SRC_DATASTORE_CAPACITY: 63488.0
    2047.8 GB
    2014-09-17 16:17:51 -- debug: SRC_DATASTORE_FREE: 1316.3 GB
    2014-09-17 16:17:51 -- debug: SRC_DATASTORE_BLOCKSIZE: 1
    2014-09-17 16:17:51 -- debug: SRC_DATASTORE_MAX_FILE_SIZE: 256 GB
    2014-09-17 16:17:51 -- debug:
    2014-09-17 16:17:51 -- debug: DST_DATASTORE: ESXI_BACKUP
    2014-09-17 16:17:51 -- debug: DST_DATASTORE_CAPACITY: 16221.8
    1833.4 GB
    2014-09-17 16:17:51 -- debug: DST_DATASTORE_FREE: 709.7 GB
    2014-09-17 16:17:51 -- debug: DST_DATASTORE_BLOCKSIZE: NA
    2014-09-17 16:17:51 -- debug: DST_DATASTORE_MAX_FILE_SIZE: NA
    2014-09-17 16:17:51 -- debug:
    2014-09-17 16:17:51 -- debug: getVMDKs() - MAIL-0.vmdk###16:
    2014-09-17 16:17:52 -- info: Initiate backup for MAIL
    2014-09-17 16:17:52 -- info: Creating Snapshot "ghettoVCB-snapshot-2014-09-17" for MAIL
    /bin/vim-cmd vmsvc/snapshot.create 100 ghettoVCB-snapshot-2014-09-17 ghettoVCB-snapshot-2014-09-17 0 0
    2014-09-17 16:17:53 -- debug: Waiting for snapshot "ghettoVCB-snapshot-2014-09-17" to be created
    2014-09-17 16:17:53 -- debug: Snapshot timeout set to: 900 seconds
    2014-09-17 16:17:53 -- debug: findVMDK() - Searching for VMDK: "MAIL-0.vmdk" to backup
    2014-09-17 16:17:53 -- debug: /sbin/vmkfstools -i "/vmfs/volumes/ESXI_DATA/MAIL/MAIL-0.vmdk" -a "lsilogic" -d "thin" "/vmfs/volumes/ESXI_BACKUP/DAILY/ghettoVCB/MAIL/MAIL-2014-09-18_01-12-19/MAIL-0.vmdk"
    Destination disk format: VMFS thin-provisioned
    Cloning disk '/vmfs/volumes/ESXI_DATA/MAIL/MAIL-0.vmdk'...
    Clone: 100% done.
    /bin/vim-cmd vmsvc/snapshot.remove 100 1
    2014-09-17 16:20:31 -- info: Removing snapshot from MAIL ...
    2014-09-17 16:20:31 -- debug: Removing /vmfs/volumes/ESXI_BACKUP/DAILY/ghettoVCB/MAIL/MAIL-2014-09-16_21-32-38
    2014-09-17 16:20:31 -- info: Backup Duration: 2.65 Minutes
    2014-09-17 16:20:31 -- info: Successfully completed backup for MAIL! 
    
    2014-09-17 16:20:34 -- debug: Storage Information after backup:
    2014-09-17 16:20:34 -- debug: SRC_DATASTORE: ESXI_DATA
    2014-09-17 16:20:34 -- debug: SRC_DATASTORE_CAPACITY: 63488.0
    2047.8 GB
    2014-09-17 16:20:34 -- debug: SRC_DATASTORE_FREE: 1316.3 GB
    2014-09-17 16:20:34 -- debug: SRC_DATASTORE_BLOCKSIZE: 1
    2014-09-17 16:20:34 -- debug: SRC_DATASTORE_MAX_FILE_SIZE: 256 GB
    2014-09-17 16:20:34 -- debug:
    2014-09-17 16:20:34 -- debug: DST_DATASTORE: ESXI_BACKUP
    2014-09-17 16:20:34 -- debug: DST_DATASTORE_CAPACITY: 16221.8
    1833.4 GB
    2014-09-17 16:20:34 -- debug: DST_DATASTORE_FREE: 709.7 GB
    2014-09-17 16:20:34 -- debug: DST_DATASTORE_BLOCKSIZE: NA
    2014-09-17 16:20:34 -- debug: DST_DATASTORE_MAX_FILE_SIZE: NA
    2014-09-17 16:20:34 -- debug:
    2014-09-17 16:20:34 -- info: ###### Final status: All VMs backed up OK! ######
    
    2014-09-17 16:20:34 -- debug: Succesfully removed lock directory - /tmp/ghettoVCB.work
    
    2014-09-17 16:20:34 -- info: ============================== ghettoVCB LOG END ================================

  7. バックアップの確認
    # ls -l /vmfs/volumes/ESXI_BACKUP/DAILY/ghettoVCB/WEB
    drwxr-xr-x    1 root     root          4096 Sep 17 16:17 WEB-2014-09-18_01-12-19
    # ls -l /vmfs/volumes/ESXI_BACKUP/DAILY/ghettoVCB/MAIL
    drwxr-xr-x    1 root     root          4096 Sep 17 16:20 MAIL-2014-09-18_01-12-19

cronの設定

注意

  • linuxのcronと違い、ESXiを再起動するとcron設定が初期化される。
    そのため、/etc/rc.localにESXiを再起動するたびにcron設定をするように変更をする。

    以下、現時点のMy自宅鯖の設定内容
    #vi /etc/rc.local
    #! /bin/sh
    
    rcdir="$1"
    if [ -z "${rcdir}" ] ; then
       rcdir=/etc/rc.local.d
    fi
    
    export PATH=/sbin:/bin
    
    log() {
       echo "$1"
       logger init "$1"
       esxcfg-init --set-boot-status-text "$1"
       esxcfg-init --set-boot-progress step
    }
    
    # execute all services registered in ${rcdir}
    if [ -d "${rcdir}" ] ; then
       for filename in $(find ${rcdir} -type f -not -name ".*" | sort) ; do
          if [ -f "${filename}" ] && [ -x "${filename}" ]; then
             log "Running $(basename ${filename})"
             "${filename}"
          fi
       done
    fi

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2016-07-05 (火) 11:46:08 (442d)