This script performs backups of virtual machines residing on ESX(i) 3.5/4.x/5.x/6.x/7.x servers using methodology similar to VMware's VCB tool. The script takes snapshots of live running virtual machines, backs up the master VMDK(s) and then upon completion, deletes the snapshot until the next backup. The only caveat is that it utilizes resources available to the Service Console of the ESX server or Busybox Console (Tech Support Mode) of the ESXi server running the backups as opposed to following the traditional method of offloading virtual machine backups through a VCB proxy.
This script has been tested on ESX 3.5/4.x/5.x and ESXi 3.5/4.x/5.x/6.x/7.x and supports the following backup mediums: LOCAL STORAGE, SAN and NFS. The script is non-interactive and can be setup to run via cron. Currently, this script accepts a text file that lists the display names of virtual machine(s) that are to be backed up. Additionally, one can specify a folder containing configuration files on a per VM basis for granular control over backup policies.
Additionally, for ESX(i) environments that don't have persistent NFS datastores designated for backups, the script offers the ability to automatically connect the ESX(i) server to a NFS exported folder and then upon backup completion, disconnect it from the ESX(i) server. The connection is established by creating an NFS datastore link which enables monolithic (or thick) VMDK backups as opposed to using the usual *nix mount command which necessitates breaking VMDK files into the 2gbsparse format for backup. Enabling this mode is self-explanatory and will evidently be so when editing the script (Note: VM_BACKUP_VOLUME variable is ignored if ENABLE_NON_PERSISTENT_NFS=1 ).
In its current configuration, the script will allow up to 3 unique backups of the Virtual Machine before it will overwrite the previous backups; this however, can be modified to fit procedures if need be. Please be diligent in running the script in a test or staging environment before using it on production live Virtual Machines; this script functions well within our environment but there is a chance that it may not fit well into other environments.
If you have any questions, you may post in the dedicated ghettoVCB VMTN community group.
If you have found this script to be useful and would like to contribute back, please click here to donate.
Please read ALL documentation + FAQ's before posting a question about an issue or problem. Thank You
1) Download ghettoVCB from github 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
4) Before using the scripts, you will need to enable the execute permission on both ghettoVCB.sh and ghettoVCB-restore.sh by running the following:
chmod +x ghettoVCB.shchmod +x ghettoVCB-restore.sh
The following variables need to be defined within the script or in VM backup policy prior to execution.
Defining the backup datastore and folder in which the backups are stored (if folder does not exist, it will automatically be created):
VM_BACKUP_VOLUME=/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS
Defining the backup disk format (zeroedthick, eagerzeroedthick, thin, and 2gbsparse are available):
DISK_BACKUP_FORMAT=thin
Note: If you are using the 2gbsparse on an ESXi 5.1 host, backups may fail. Please download the latest version of the ghettoVCB script which automatically resolves this or take a look at this article for the details.
Defining the backup rotation per VM:
VM_BACKUP_ROTATION_COUNT=3
Defining whether the VM is powered down or not prior to backup (1 = enable, 0 = disable):
Note: VM(s) that are powered off will not require snapshoting
POWER_VM_DOWN_BEFORE_BACKUP=0
Defining whether the VM can be hard powered off when "POWER_VM_DOWN_BEFORE_BACKUP" is enabled and VM does not have VMware Tools installed
ENABLE_HARD_POWER_OFF=0
If "ENABLE_HARD_POWER_OFF" is enabled, then this defines the number of (60sec) iterations the script will before executing a hard power off when:
ITER_TO_WAIT_SHUTDOWN=3
The number (60sec) iterations the script will wait when powering off the VM and will give up and ignore the particular VM for backup:
POWER_DOWN_TIMEOUT=5
The number (60sec) iterations the script will wait when taking a snapshot of a VM and will give up and ignore the particular VM for backup:
Note: Default value should suffice
SNAPSHOT_TIMEOUT=15
Defining whether or not to enable compression (1 = enable, 0 = disable):
ENABLE_COMPRESSION=0
NOTE: With ESXi 3.x/4.x/5.x, there is a limitation of the maximum size of a VM for compression within the unsupported Busybox Console which should not affect backups running classic ESX 3.x,4.x or 5.x. On ESXi 3.x the largest supported VM is 4GB for compression and on ESXi 4.x the largest supported VM is 8GB. If you try to compress a larger VM, you may run into issues when trying to extract upon a restore. PLEASE TEST THE RESTORE PROCESS BEFORE MOVING TO PRODUCTION SYSTEMS!
Defining the adapter type for backed up VMDK (DEPERCATED - NO LONGER NEEDED😞
ADAPTER_FORMAT=buslogic
Defining whether virtual machine memory is snapped and if quiescing is enabled (1 = enable, 0 = disable):
Note: By default both are disabled
VM_SNAPSHOT_MEMORY=0
VM_SNAPSHOT_QUIESCE=0
NOTE: VM_SNAPSHOT_MEMORY is only used to ensure when the snapshot is taken, it's memory contents are also captured. This is only relevant to the actual snapshot and it's not used in any shape/way/form in regards to the backup. All backups taken whether your VM is running or offline will result in an offline VM backup when you restore. This was originally added for debugging purposes and in generally should be left disabled
Defining VMDK(s) to backup from a particular VM either a list of vmdks or "all"
VMDK_FILES_TO_BACKUP="myvmdk.vmdk"
Defining whether or not VM(s) with existing snapshots can be backed up. This flag means it will CONSOLIDATE ALL EXISTING SNAPSHOTS for a VM prior to starting the backup (1 = yes, 0 = no):
ALLOW_VMS_WITH_SNAPSHOTS_TO_BE_BACKEDUP=0
Defining the order of which VM(s) should be shutdown first, especially if there is a dependency between multiple VM(s). This should be a comma seperate list of VM(s)
VM_SHUTDOWN_ORDER=vm1,vm2,vm3
Defining the order of VM(s) that should be started up first after backups have completed, especially if there is a dependency between multiple VM(s). This should be a comma seperate list of VM(s)
VM_STARTUP_ORDER=vm3,vm2,vm1
Defining NON-PERSISTENT NFS Backup Volume (1 = yes, 0 = no):
ENABLE_NON_PERSISTENT_NFS=0
NOTE: This is meant for environments that do not want a persisted connection to their NFS backup volume and allows the NFS volume to only be mounted during backups. The script expects the following 5 variables to be defined if this is to be used: UNMOUNT_NFS, NFS_SERVER, NFS_MOUNT, NFS_LOCAL_NAME and NFS_VM_BACKUP_DIR
Defining whether or not to unmount the NFS backup volume (1 = yes, 0 = no):
UNMOUNT_NFS=0
Defining the NFS server address (IP/hostname):
NFS_SERVER=172.51.0.192
Defining the NFS export path:
NFS_MOUNT=/upload
Defining the NFS datastore name:
NFS_LOCAL_NAME=backup
Defining the NFS backup directory for VMs:
NFS_VM_BACKUP_DIR=mybackups
NOTE: Only supported if you are running vSphere 4.1 and this feature is experimental. If you are having issues with sending mail, please take a look at Email Backup Log section
Defining whether or not to email backup logs (1 = yes, 0 = no):
EMAIL_LOG=1
Defining whether or not to email message will be deleted off the host whether it is successful in sending, this is used for debugging purposes. (1 = yes, 0 = no):
EMAIL_DEBUG=1
Defining email server:
EMAIL_SERVER=auroa.primp-industries.com
Defining email server port:
EMAIL_SERVER_PORT=25
Defining email delay interval (useful if you have slow SMTP server and would like to include a delay in netcat using -i param, default is 1second):
EMAIL_DELAY_INTERVAL=1
Defining recipient of the email:
EMAIL_TO=auroa@primp-industries.com
Defining from user which may require specific domain entry depending on email server configurations:
EMAIL_FROM=root@ghettoVCB
Defining to support RSYNC symbolic link creation (1 = yes, 0 = no):
RSYNC_LINK=0
Note: This enables an automatic creation of a generic symbolic link (both a relative & absolution path) in which users can refer to run replication backups using rsync from a remote host. This does not actually support rsync backups with ghettoVCB. Please take a look at the Rsync Section of the documentation for more details.
# cat ghettoVCB.conf
VM_BACKUP_VOLUME=/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS
DISK_BACKUP_FORMAT=thin
VM_BACKUP_ROTATION_COUNT=3
POWER_VM_DOWN_BEFORE_BACKUP=0
ENABLE_HARD_POWER_OFF=0
ITER_TO_WAIT_SHUTDOWN=3
POWER_DOWN_TIMEOUT=5
ENABLE_COMPRESSION=0
VM_SNAPSHOT_MEMORY=0
VM_SNAPSHOT_QUIESCE=0
ALLOW_VMS_WITH_SNAPSHOTS_TO_BE_BACKEDUP=0
ENABLE_NON_PERSISTENT_NFS=0
UNMOUNT_NFS=0
NFS_SERVER=172.30.0.195
NFS_MOUNT=/nfsshare
NFS_LOCAL_NAME=nfs_storage_backup
NFS_VM_BACKUP_DIR=mybackups
SNAPSHOT_TIMEOUT=15
EMAIL_LOG=0
EMAIL_SERVER=auroa.primp-industries.com
EMAIL_SERVER_PORT=25
EMAIL_DELAY_INTERVAL=1
EMAIL_TO=auroa@primp-industries.com
EMAIL_FROM=root@ghettoVCB
WORKDIR_DEBUG=0
VM_SHUTDOWN_ORDER=
VM_STARTUP_ORDER=
To override any existing configurations within the ghettoVCB.sh script and to use a global configuration file, user just needs to specify the new flag -g and path to global configuration file (For an example, please refer to the sample execution section of the documenation)
Running multiple instances of ghettoVCB is now supported with the latest release by specifying the working directory (-w) flag.
By default, the working directory of the ghettoVCB instance is /tmp/ghettoVCB.work and you can run another instance by providing an alternate working directory. You should try to minimize the number of ghettoVCB instances running on your ESXi host as it does consume some amount of resources when running in the ESXi Shell. This is considered an experimental feature, so please test in a development environment to ensure everything is working prior to moving to production system.
Ensure that you do not edit past this section:
########################## DO NOT MODIFY PAST THIS LINE ##########################
# ./ghettoVCB.sh
###############################################################################
#
# ghettoVCB for ESX/ESXi 3.5, 4.x+ and 5.x
# Author: William Lam
# http://www.virtuallyghetto.com/
# Documentation: http://communities.vmware.com/docs/DOC-8760
# Created: 11/17/2008
# Last modified: 2012_12_17 Version 0
#
###############################################################################
Usage: ghettoVCB.sh [options]
OPTIONS:
-a Backup all VMs on host
-f List of VMs to backup
-m Name of VM to backup (overrides -f)
-c VM configuration directory for VM backups
-g Path to global ghettoVCB configuration file
-l File to output logging
-w ghettoVCB work directory (default: )
-d Debug level [info|debug|dryrun] (default: info)
(e.g.)
Backup VMs stored in a list
./ghettoVCB.sh -f vms_to_backup
Backup a single VM
./ghettoVCB.sh -m vm_to_backup
Backup all VMs residing on this host
./ghettoVCB.sh -a
Backup all VMs residing on this host except for the VMs in the exclusion list
./ghettoVCB.sh -a -e vm_exclusion_list
Backup VMs based on specific configuration located in directory
./ghettoVCB.sh -f vms_to_backup -c vm_backup_configs
Backup VMs using global ghettoVCB configuration file
./ghettoVCB.sh -f vms_to_backup -g /global/ghettoVCB.conf
Output will log to /tmp/ghettoVCB.log (consider logging to local or remote datastore to persist logs)
./ghettoVCB.sh -f vms_to_backup -l /vmfs/volume/local-storage/ghettoVCB.log
Dry run (no backup will take place)
./ghettoVCB.sh -f vms_to_backup -d dryrun
The input to this script is a file that contains the display name of the virtual machine(s) separated by a newline. When creating this file on a non-Linux/UNIX system, you may introduce ^M character which can cause the script to miss-behave. To ensure this does not occur, plesae create the file on the ESX/ESXi host.
Here is a sample of what the file would look like:
[root@himalaya ~]# cat vms_to_backup
vCOPS
vMA
vCloudConnector
Debug Mode
Note: This execution mode provides a qucik summary of details on whether a given set of VM(s)/VMDK(s) will be backed up. It provides additional information such as VMs that may have snapshots, VMDK(s) that are configured as independent disks, or other issues that may cause a VM or VMDK to not backed up.
[root@himalaya ghettoVCB]# ./ghettoVCB.sh -f vms_to_backup -d dryrun
Logging output to "/tmp/ghettoVCB-2011-03-13_15-19-57.log" ...
2011-03-13 15:19:57 -- info: ============================== ghettoVCB LOG START ==============================
2011-03-13 15:19:57 -- info: CONFIG - VERSION = 2011_03_13_1
2011-03-13 15:19:57 -- info: CONFIG - GHETTOVCB_PID = 30157
2011-03-13 15:19:57 -- info: CONFIG - VM_BACKUP_VOLUME = /vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS
2011-03-13 15:19:57 -- info: CONFIG - VM_BACKUP_ROTATION_COUNT = 3
2011-03-13 15:19:57 -- info: CONFIG - VM_BACKUP_DIR_NAMING_CONVENTION = 2011-03-13_15-19-57
2011-03-13 15:19:57 -- info: CONFIG - DISK_BACKUP_FORMAT = thin
2011-03-13 15:19:57 -- info: CONFIG - POWER_VM_DOWN_BEFORE_BACKUP = 0
2011-03-13 15:19:57 -- info: CONFIG - ENABLE_HARD_POWER_OFF = 0
2011-03-13 15:19:57 -- info: CONFIG - ITER_TO_WAIT_SHUTDOWN = 3
2011-03-13 15:19:57 -- info: CONFIG - POWER_DOWN_TIMEOUT = 5
2011-03-13 15:19:57 -- info: CONFIG - SNAPSHOT_TIMEOUT = 15
2011-03-13 15:19:57 -- info: CONFIG - LOG_LEVEL = dryrun
2011-03-13 15:19:57 -- info: CONFIG - BACKUP_LOG_OUTPUT = /tmp/ghettoVCB-2011-03-13_15-19-57.log
2011-03-13 15:19:57 -- info: CONFIG - VM_SNAPSHOT_MEMORY = 0
2011-03-13 15:19:57 -- info: CONFIG - VM_SNAPSHOT_QUIESCE = 0
2011-03-13 15:19:57 -- info: CONFIG - VMDK_FILES_TO_BACKUP = all
2011-03-13 15:19:57 -- info: CONFIG - EMAIL_LOG = 0
2011-03-13 15:19:57 -- info:
2011-03-13 15:19:57 -- dryrun: ###############################################
2011-03-13 15:19:57 -- dryrun: Virtual Machine: scofield
2011-03-13 15:19:57 -- dryrun: VM_ID: 704
2011-03-13 15:19:57 -- dryrun: VMX_PATH: /vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage/scofield/scofield.vmx
2011-03-13 15:19:57 -- dryrun: VMX_DIR: /vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage/scofield
2011-03-13 15:19:57 -- dryrun: VMX_CONF: scofield/scofield.vmx
2011-03-13 15:19:57 -- dryrun: VMFS_VOLUME: himalaya-local-SATA.RE4-GP:Storage
2011-03-13 15:19:57 -- dryrun: VMDK(s):
2011-03-13 15:19:58 -- dryrun: scofield_3.vmdk 3 GB
2011-03-13 15:19:58 -- dryrun: scofield_2.vmdk 2 GB
2011-03-13 15:19:58 -- dryrun: scofield_1.vmdk 1 GB
2011-03-13 15:19:58 -- dryrun: scofield.vmdk 5 GB
2011-03-13 15:19:58 -- dryrun: INDEPENDENT VMDK(s):
2011-03-13 15:19:58 -- dryrun: TOTAL_VM_SIZE_TO_BACKUP: 11 GB
2011-03-13 15:19:58 -- dryrun: ###############################################
2011-03-13 15:19:58 -- dryrun: ###############################################
2011-03-13 15:19:58 -- dryrun: Virtual Machine: vMA
2011-03-13 15:19:58 -- dryrun: VM_ID: 1440
2011-03-13 15:19:58 -- dryrun: VMX_PATH: /vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage/vMA/vMA.vmx
2011-03-13 15:19:58 -- dryrun: VMX_DIR: /vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage/vMA
2011-03-13 15:19:58 -- dryrun: VMX_CONF: vMA/vMA.vmx
2011-03-13 15:19:58 -- dryrun: VMFS_VOLUME: himalaya-local-SATA.RE4-GP:Storage
2011-03-13 15:19:58 -- dryrun: VMDK(s):
2011-03-13 15:19:58 -- dryrun: vMA-000002.vmdk 5 GB
2011-03-13 15:19:58 -- dryrun: INDEPENDENT VMDK(s):
2011-03-13 15:19:58 -- dryrun: TOTAL_VM_SIZE_TO_BACKUP: 5 GB
2011-03-13 15:19:58 -- dryrun: Snapshots found for this VM, please commit all snapshots before continuing!
2011-03-13 15:19:58 -- dryrun: THIS VIRTUAL MACHINE WILL NOT BE BACKED UP DUE TO EXISTING SNAPSHOTS!
2011-03-13 15:19:58 -- dryrun: ###############################################
2011-03-13 15:19:58 -- dryrun: ###############################################
2011-03-13 15:19:58 -- dryrun: Virtual Machine: vCloudConnector
2011-03-13 15:19:58 -- dryrun: VM_ID: 2064
2011-03-13 15:19:58 -- dryrun: VMX_PATH: /vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage/vCloudConnector/vCloudConnector.vmx
2011-03-13 15:19:58 -- dryrun: VMX_DIR: /vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage/vCloudConnector
2011-03-13 15:19:58 -- dryrun: VMX_CONF: vCloudConnector/vCloudConnector.vmx
2011-03-13 15:19:58 -- dryrun: VMFS_VOLUME: himalaya-local-SATA.RE4-GP:Storage
2011-03-13 15:19:58 -- dryrun: VMDK(s):
2011-03-13 15:19:59 -- dryrun: vCloudConnector.vmdk 3 GB
2011-03-13 15:19:59 -- dryrun: INDEPENDENT VMDK(s):
2011-03-13 15:19:59 -- dryrun: vCloudConnector_1.vmdk 40 GB
2011-03-13 15:19:59 -- dryrun: TOTAL_VM_SIZE_TO_BACKUP: 3 GB
2011-03-13 15:19:59 -- dryrun: Snapshots can not be taken for indepdenent disks!
2011-03-13 15:19:59 -- dryrun: THIS VIRTUAL MACHINE WILL NOT HAVE ALL ITS VMDKS BACKED UP!
2011-03-13 15:19:59 -- dryrun: ###############################################
2011-03-13 15:19:59 -- info: ###### Final status: OK, only a dryrun. ######
2011-03-13 15:19:59 -- info: ============================== ghettoVCB LOG END ================================
In the example above, we have 3 VMs to be backed up:
Note: This execution modes provides more in-depth information about environment/backup process including additional storage debugging information which provides information about both the source/destination datastore pre and post backups. This can be very useful in troubleshooting backups
[root@himalaya ghettoVCB]# ./ghettoVCB.sh -f vms_to_backup -d debug
Logging output to "/tmp/ghettoVCB-2011-03-13_15-27-59.log" ...
2011-03-13 15:27:59 -- info: ============================== ghettoVCB LOG START ==============================
2011-03-13 15:27:59 -- debug: Succesfully acquired lock directory - /tmp/ghettoVCB.lock
2011-03-13 15:27:59 -- debug: HOST VERSION: VMware ESX 4.1.0 build-260247
2011-03-13 15:27:59 -- debug: HOST LEVEL: VMware ESX 4.1.0 GA
2011-03-13 15:27:59 -- debug: HOSTNAME: himalaya.primp-industries.com
2011-03-13 15:27:59 -- info: CONFIG - VERSION = 2011_03_13_1
2011-03-13 15:27:59 -- info: CONFIG - GHETTOVCB_PID = 31074
2011-03-13 15:27:59 -- info: CONFIG - VM_BACKUP_VOLUME = /vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS
2011-03-13 15:27:59 -- info: CONFIG - VM_BACKUP_ROTATION_COUNT = 3
2011-03-13 15:27:59 -- info: CONFIG - VM_BACKUP_DIR_NAMING_CONVENTION = 2011-03-13_15-27-59
2011-03-13 15:27:59 -- info: CONFIG - DISK_BACKUP_FORMAT = thin
2011-03-13 15:27:59 -- info: CONFIG - POWER_VM_DOWN_BEFORE_BACKUP = 0
2011-03-13 15:27:59 -- info: CONFIG - ENABLE_HARD_POWER_OFF = 0
2011-03-13 15:27:59 -- info: CONFIG - ITER_TO_WAIT_SHUTDOWN = 3
2011-03-13 15:27:59 -- info: CONFIG - POWER_DOWN_TIMEOUT = 5
2011-03-13 15:27:59 -- info: CONFIG - SNAPSHOT_TIMEOUT = 15
2011-03-13 15:27:59 -- info: CONFIG - LOG_LEVEL = debug
2011-03-13 15:27:59 -- info: CONFIG - BACKUP_LOG_OUTPUT = /tmp/ghettoVCB-2011-03-13_15-27-59.log
2011-03-13 15:27:59 -- info: CONFIG - VM_SNAPSHOT_MEMORY = 0
2011-03-13 15:27:59 -- info: CONFIG - VM_SNAPSHOT_QUIESCE = 0
2011-03-13 15:27:59 -- info: CONFIG - VMDK_FILES_TO_BACKUP = all
2011-03-13 15:27:59 -- info: CONFIG - EMAIL_LOG = 0
2011-03-13 15:27:59 -- info:
2011-03-13 15:28:01 -- debug: Storage Information before backup:
2011-03-13 15:28:01 -- debug: SRC_DATASTORE: himalaya-local-SATA.RE4-GP:Storage
2011-03-13 15:28:01 -- debug: SRC_DATASTORE_CAPACITY: 1830.5 GB
2011-03-13 15:28:01 -- debug: SRC_DATASTORE_FREE: 539.4 GB
2011-03-13 15:28:01 -- debug: SRC_DATASTORE_BLOCKSIZE: 4
2011-03-13 15:28:01 -- debug: SRC_DATASTORE_MAX_FILE_SIZE: 1024 GB
2011-03-13 15:28:01 -- debug:
2011-03-13 15:28:01 -- debug: DST_DATASTORE: dlgCore-NFS-bigboi.VM-Backups
2011-03-13 15:28:01 -- debug: DST_DATASTORE_CAPACITY: 1348.4 GB
2011-03-13 15:28:01 -- debug: DST_DATASTORE_FREE: 296.8 GB
2011-03-13 15:28:01 -- debug: DST_DATASTORE_BLOCKSIZE: NA
2011-03-13 15:28:01 -- debug: DST_DATASTORE_MAX_FILE_SIZE: NA
2011-03-13 15:28:01 -- debug:
2011-03-13 15:28:02 -- info: Initiate backup for scofield
2011-03-13 15:28:02 -- debug: /usr/sbin/vmkfstools -i "/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage/scofield/scofield_3.vmdk" -a "buslogic" -d "thin" "/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/scofield/scofield-2011-03-13_15-27-59/scofield_3.vmdk"
Destination disk format: VMFS thin-provisioned
Cloning disk '/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage/scofield/scofield_3.vmdk'...
Clone: 37% done.
2011-03-13 15:28:04 -- debug: /usr/sbin/vmkfstools -i "/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage/scofield/scofield_2.vmdk" -a "buslogic" -d "thin" "/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/scofield/scofield-2011-03-13_15-27-59/scofield_2.vmdk"
Destination disk format: VMFS thin-provisioned
Cloning disk '/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage/scofield/scofield_2.vmdk'...
Clone: 85% done.
2011-03-13 15:28:05 -- debug: /usr/sbin/vmkfstools -i "/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage/scofield/scofield_1.vmdk" -a "buslogic" -d "thin" "/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/scofield/scofield-2011-03-13_15-27-59/scofield_1.vmdk"
2011-03-13 15:28:06 -- debug: /usr/sbin/vmkfstools -i "/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage/scofield/scofield.vmdk" -a "buslogic" -d "thin" "/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/scofield/scofield-2011-03-13_15-27-59/scofield.vmdk"
Destination disk format: VMFS thin-provisioned
Cloning disk '/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage/scofield/scofield.vmdk'...
Clone: 78% done.
2011-03-13 15:29:52 -- info: Backup Duration: 1.83 Minutes
2011-03-13 15:29:52 -- info: Successfully completed backup for scofield!
2011-03-13 15:29:54 -- debug: Storage Information after backup:
2011-03-13 15:29:54 -- debug: SRC_DATASTORE: himalaya-local-SATA.RE4-GP:Storage
2011-03-13 15:29:54 -- debug: SRC_DATASTORE_CAPACITY: 1830.5 GB
2011-03-13 15:29:54 -- debug: SRC_DATASTORE_FREE: 539.4 GB
2011-03-13 15:29:54 -- debug: SRC_DATASTORE_BLOCKSIZE: 4
2011-03-13 15:29:54 -- debug: SRC_DATASTORE_MAX_FILE_SIZE: 1024 GB
2011-03-13 15:29:54 -- debug:
2011-03-13 15:29:54 -- debug: DST_DATASTORE: dlgCore-NFS-bigboi.VM-Backups
2011-03-13 15:29:54 -- debug: DST_DATASTORE_CAPACITY: 1348.4 GB
2011-03-13 15:29:54 -- debug: DST_DATASTORE_FREE: 296.8 GB
2011-03-13 15:29:54 -- debug: DST_DATASTORE_BLOCKSIZE: NA
2011-03-13 15:29:54 -- debug: DST_DATASTORE_MAX_FILE_SIZE: NA
2011-03-13 15:29:54 -- debug:
2011-03-13 15:29:55 -- debug: Storage Information before backup:
2011-03-13 15:29:55 -- debug: SRC_DATASTORE: himalaya-local-SATA.RE4-GP:Storage
2011-03-13 15:29:55 -- debug: SRC_DATASTORE_CAPACITY: 1830.5 GB
2011-03-13 15:29:55 -- debug: SRC_DATASTORE_FREE: 539.4 GB
2011-03-13 15:29:55 -- debug: SRC_DATASTORE_BLOCKSIZE: 4
2011-03-13 15:29:55 -- debug: SRC_DATASTORE_MAX_FILE_SIZE: 1024 GB
2011-03-13 15:29:55 -- debug:
2011-03-13 15:29:55 -- debug: DST_DATASTORE: dlgCore-NFS-bigboi.VM-Backups
2011-03-13 15:29:55 -- debug: DST_DATASTORE_CAPACITY: 1348.4 GB
2011-03-13 15:29:55 -- debug: DST_DATASTORE_FREE: 296.8 GB
2011-03-13 15:29:55 -- debug: DST_DATASTORE_BLOCKSIZE: NA
2011-03-13 15:29:55 -- debug: DST_DATASTORE_MAX_FILE_SIZE: NA
2011-03-13 15:29:55 -- debug:
2011-03-13 15:29:55 -- info: Snapshot found for vMA, backup will not take place
2011-03-13 15:29:57 -- debug: Storage Information before backup:
2011-03-13 15:29:57 -- debug: SRC_DATASTORE: himalaya-local-SATA.RE4-GP:Storage
2011-03-13 15:29:57 -- debug: SRC_DATASTORE_CAPACITY: 1830.5 GB
2011-03-13 15:29:57 -- debug: SRC_DATASTORE_FREE: 539.4 GB
2011-03-13 15:29:57 -- debug: SRC_DATASTORE_BLOCKSIZE: 4
2011-03-13 15:29:57 -- debug: SRC_DATASTORE_MAX_FILE_SIZE: 1024 GB
2011-03-13 15:29:57 -- debug:
2011-03-13 15:29:57 -- debug: DST_DATASTORE: dlgCore-NFS-bigboi.VM-Backups
2011-03-13 15:29:57 -- debug: DST_DATASTORE_CAPACITY: 1348.4 GB
2011-03-13 15:29:57 -- debug: DST_DATASTORE_FREE: 296.8 GB
2011-03-13 15:29:57 -- debug: DST_DATASTORE_BLOCKSIZE: NA
2011-03-13 15:29:57 -- debug: DST_DATASTORE_MAX_FILE_SIZE: NA
2011-03-13 15:29:57 -- debug:
2011-03-13 15:29:58 -- info: Initiate backup for vCloudConnector
2011-03-13 15:29:58 -- debug: /usr/sbin/vmkfstools -i "/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage/vCloudConnector/vCloudConnector.vmdk" -a "buslogic" -d "thin" "/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/vCloudConnector/vCloudConnector-2011-03-13_15-27-59/vCloudConnector.vmdk"
Destination disk format: VMFS thin-provisioned
Cloning disk '/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage/vCloudConnector/vCloudConnector.vmdk'...
Clone: 97% done.
2011-03-13 15:30:45 -- info: Backup Duration: 47 Seconds
2011-03-13 15:30:45 -- info: WARN: vCloudConnector has some Independent VMDKs that can not be backed up!
2011-03-13 15:30:45 -- info: ###### Final status: ERROR: Only some of the VMs backed up, and some disk(s) failed! ######
2011-03-13 15:30:45 -- debug: Succesfully removed lock directory - /tmp/ghettoVCB.lock
2011-03-13 15:30:45 -- info: ============================== ghettoVCB LOG END ================================
[root@himalaya ~]# ./ghettoVCB.sh -f vms_to_backup
# ./ghettoVCB.sh -m MyVM
/ghettoVCB # ./ghettoVCB.sh -a
/ghettoVCB # ./ghettoVCB.sh -a -e vm_exclusion_list
1. Create folder to hold individual VM backup policies (can be named anything):
[root@himalaya ~]# mkdir backup_config
2. Create individual VM backup policies for each VM that ensure each file is named exactly as the display name of the VM being backed up (use provided template to create duplicates):
[root@himalaya backup_config]# cp ghettoVCB-vm_backup_configuration_template scofield
[root@himalaya backup_config]# cp ghettoVCB-vm_backup_configuration_template vCloudConnector
Listing of VM backup policy within backup configuration directory
[root@himalaya backup_config]# ls
scofield vCloudConnector
ghettoVCB-vm_backup_configuration_template
Backup policy for "scofield" (backup only 2 specific VMDKs)
[root@himalaya backup_config]# cat scofield
scofield_2.vmdk,scofield_1.vmdk
VM_BACKUP_VOLUME=/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS
DISK_BACKUP_FORMAT=thin
VM_BACKUP_ROTATION_COUNT=3
POWER_VM_DOWN_BEFORE_BACKUP=0
ENABLE_HARD_POWER_OFF=0
ITER_TO_WAIT_SHUTDOWN=4
POWER_DOWN_TIMEOUT=5
SNAPSHOT_TIMEOUT=15
ENABLE_COMPRESSION=0
VM_SNAPSHOT_MEMORY=0
VM_SNAPSHOT_QUIESCE=0
VMDK_FILES_TO_BACKUP=""
Backup policy for VM "vCloudConnector" (backup all VMDKs found)
[root@himalaya backup_config]# cat
vCloudConnectorVM_BACKUP_VOLUME=/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS
vCloudConnector.vmdk
DISK_BACKUP_FORMAT=thin
VM_BACKUP_ROTATION_COUNT=3
POWER_VM_DOWN_BEFORE_BACKUP=0
ENABLE_HARD_POWER_OFF=0
ITER_TO_WAIT_SHUTDOWN=4
POWER_DOWN_TIMEOUT=5
SNAPSHOT_TIMEOUT=15
ENABLE_COMPRESSION=0
VM_SNAPSHOT_MEMORY=0
VM_SNAPSHOT_QUIESCE=0
VMDK_FILES_TO_BACKUP=""
Note: When specifying -c option (individual VM backup policy mode) if a VM is listed in the backup list but DOES NOT have a corresponding backup policy, the VM will be backed up using the default configuration found within the ghettoVCB.sh script.
Execution of backup
[root@himalaya ~]# ./ghettoVCB.sh -f vms_to_backup -c backup_config -l /tmp/ghettoVCB.log
2011-03-13 15:40:50 -- info: ============================== ghettoVCB LOG START ==============================
2011-03-13 15:40:51 -- info: CONFIG - USING CONFIGURATION FILE = backup_config//scofield
2011-03-13 15:40:51 -- info: CONFIG - VERSION = 2011_03_13_1
2011-03-13 15:40:51 -- info: CONFIG - GHETTOVCB_PID = 2967
2011-03-13 15:40:51 -- info: CONFIG - VM_BACKUP_VOLUME = /vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS
2011-03-13 15:40:51 -- info: CONFIG - VM_BACKUP_ROTATION_COUNT = 3
2011-03-13 15:40:51 -- info: CONFIG - VM_BACKUP_DIR_NAMING_CONVENTION = 2011-03-13_15-40-50
2011-03-13 15:40:51 -- info: CONFIG - DISK_BACKUP_FORMAT = thin
2011-03-13 15:40:51 -- info: CONFIG - POWER_VM_DOWN_BEFORE_BACKUP = 0
2011-03-13 15:40:51 -- info: CONFIG - ENABLE_HARD_POWER_OFF = 0
2011-03-13 15:40:51 -- info: CONFIG - ITER_TO_WAIT_SHUTDOWN = 4
2011-03-13 15:40:51 -- info: CONFIG - POWER_DOWN_TIMEOUT = 5
2011-03-13 15:40:51 -- info: CONFIG - SNAPSHOT_TIMEOUT = 15
2011-03-13 15:40:51 -- info: CONFIG - LOG_LEVEL = info
2011-03-13 15:40:51 -- info: CONFIG - BACKUP_LOG_OUTPUT = /tmp/ghettoVCB.log
2011-03-13 15:40:51 -- info: CONFIG - VM_SNAPSHOT_MEMORY = 0
2011-03-13 15:40:51 -- info: CONFIG - VM_SNAPSHOT_QUIESCE = 0
2011-03-13 15:40:51 -- info: CONFIG - VMDK_FILES_TO_BACKUP = scofield_2.vmdk,scofield_1.vmdk
2011-03-13 15:40:51 -- info: CONFIG - EMAIL_LOG = 0
2011-03-13 15:40:51 -- info:
2011-03-13 15:40:53 -- info: Initiate backup for scofield
Destination disk format: VMFS thin-provisioned
Cloning disk '/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage/scofield/scofield_2.vmdk'...
Clone: 100% done.
Destination disk format: VMFS thin-provisioned
Cloning disk '/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage/scofield/scofield_1.vmdk'...
Clone: 100% done.
2011-03-13 15:40:55 -- info: Backup Duration: 2 Seconds
2011-03-13 15:40:55 -- info: Successfully completed backup for scofield!
2011-03-13 15:40:57 -- info: CONFIG - VERSION = 2011_03_13_1
2011-03-13 15:40:57 -- info: CONFIG - GHETTOVCB_PID = 2967
2011-03-13 15:40:57 -- info: CONFIG - VM_BACKUP_VOLUME = /vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS
2011-03-13 15:40:57 -- info: CONFIG - VM_BACKUP_ROTATION_COUNT = 3
2011-03-13 15:40:57 -- info: CONFIG - VM_BACKUP_DIR_NAMING_CONVENTION = 2011-03-13_15-40-50
2011-03-13 15:40:57 -- info: CONFIG - DISK_BACKUP_FORMAT = thin
2011-03-13 15:40:57 -- info: CONFIG - POWER_VM_DOWN_BEFORE_BACKUP = 0
2011-03-13 15:40:57 -- info: CONFIG - ENABLE_HARD_POWER_OFF = 0
2011-03-13 15:40:57 -- info: CONFIG - ITER_TO_WAIT_SHUTDOWN = 3
2011-03-13 15:40:57 -- info: CONFIG - POWER_DOWN_TIMEOUT = 5
2011-03-13 15:40:57 -- info: CONFIG - SNAPSHOT_TIMEOUT = 15
2011-03-13 15:40:57 -- info: CONFIG - LOG_LEVEL = info
2011-03-13 15:40:57 -- info: CONFIG - BACKUP_LOG_OUTPUT = /tmp/ghettoVCB.log
2011-03-13 15:40:57 -- info: CONFIG - VM_SNAPSHOT_MEMORY = 0
2011-03-13 15:40:57 -- info: CONFIG - VM_SNAPSHOT_QUIESCE = 0
2011-03-13 15:40:57 -- info: CONFIG - VMDK_FILES_TO_BACKUP = all
2011-03-13 15:40:57 -- info: CONFIG - EMAIL_LOG = 0
2011-03-13 15:40:57 -- info:
2011-03-13 15:40:59 -- info: Snapshot found for vMA, backup will not take place
2011-03-13 15:40:59 -- info: CONFIG - USING CONFIGURATION FILE = backup_config//vCloudConnector
2011-03-13 15:40:59 -- info: CONFIG - VERSION = 2011_03_13_1
2011-03-13 15:40:59 -- info: CONFIG - GHETTOVCB_PID = 2967
2011-03-13 15:40:59 -- info: CONFIG - VM_BACKUP_VOLUME = /vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS
2011-03-13 15:40:59 -- info: CONFIG - VM_BACKUP_ROTATION_COUNT = 3
2011-03-13 15:40:59 -- info: CONFIG - VM_BACKUP_DIR_NAMING_CONVENTION = 2011-03-13_15-40-50
2011-03-13 15:40:59 -- info: CONFIG - DISK_BACKUP_FORMAT = thin
2011-03-13 15:40:59 -- info: CONFIG - POWER_VM_DOWN_BEFORE_BACKUP = 0
2011-03-13 15:40:59 -- info: CONFIG - ENABLE_HARD_POWER_OFF = 0
2011-03-13 15:40:59 -- info: CONFIG - ITER_TO_WAIT_SHUTDOWN = 4
2011-03-13 15:40:59 -- info: CONFIG - POWER_DOWN_TIMEOUT = 5
2011-03-13 15:40:59 -- info: CONFIG - SNAPSHOT_TIMEOUT = 15
2011-03-13 15:40:59 -- info: CONFIG - LOG_LEVEL = info
2011-03-13 15:40:59 -- info: CONFIG - BACKUP_LOG_OUTPUT = /tmp/ghettoVCB.log
2011-03-13 15:40:59 -- info: CONFIG - VM_SNAPSHOT_MEMORY = 0
2011-03-13 15:40:59 -- info: CONFIG - VM_SNAPSHOT_QUIESCE = 0
2011-03-13 15:40:59 -- info: CONFIG - VMDK_FILES_TO_BACKUP = vCloudConnector.vmdk
2011-03-13 15:40:59 -- info: CONFIG - EMAIL_LOG = 0
2011-03-13 15:40:59 -- info:
2011-03-13 15:41:01 -- info: Initiate backup for vCloudConnector
Destination disk format: VMFS thin-provisioned
Cloning disk '/vmfs/volumes/himalaya-local-SATA.RE4-GP:Storage/vCloudConnector/vCloudConnector.vmdk'...
Clone: 100% done.
2011-03-13 15:41:51 -- info: Backup Duration: 50 Seconds
2011-03-13 15:41:51 -- info: WARN: vCloudConnector has some Independent VMDKs that can not be backed up!
2011-03-13 15:41:51 -- info: ###### Final status: ERROR: Only some of the VMs backed up, and some disk(s) failed! ######
2011-03-13 15:41:51 -- info: ============================== ghettoVCB LOG END ================================
Please take a look at FAQ #25 for more details before continuing
To make use of this feature, modify the variable ENABLE_COMPRESSION from 0 to 1. Please note, do not mix uncompressed backups with compressed backups. Ensure that directories selected for backups do not contain any backups with previous versions of ghettoVCB before enabling and implementing the compressed backups feature.
nc (netcat) utility must be present for email support to function, this utility is a now a default with the release of vSphere 4.1 or greater, previous releases of VI 3.5 and/or vSphere 4.0 does not contain this utility. The reason this is listed as experimental is it may not be compatible with all email servers as the script utlizes nc (netcat) utility to communicate to an email server. This feature is provided as-is with no guarantees. If you enable this feature, a separate log will be generated along side any normal logging which will be used to email recipient. If for whatever reason, the email fails to send, an entry will appear per the normal logging mechanism.
Users should also make note due to limited functionality of netcat, it uses SMTP pipelining which is not the most ideal method of communicating with an SMTP server. Email from ghettoVCB may not work if your email server does not support this feature.
You can define an email recipient in the following two ways:
EMAIL_TO=william@virtuallyghetto.com
OR
EMAIL_TO=william@virtuallyghetto.com,tuan@virtuallyghetto.com
If you are running ESXi 5.1, you will need to create a custom firewall rule to allow your email traffic to go out which I will assume is default port 25. Here are the steps for creating a custom email rule.
Step 1 - Create a file called /etc/vmware/firewall/email.xml with contains the following:
<ConfigRoot>
<service>
<id>email</id>
<rule id="0000">
<direction>outbound</direction>
<protocol>tcp</protocol>
<porttype>dst</porttype>
<port>25</port>
</rule>
<enabled>true</enabled>
<required>false</required>
</service>
</ConfigRoot>
Step 2 - Reload the ESXi firewall by running the following ESXCLI command:
~ #
esxcli network firewall refresh
Step 3 - Confirm that your email rule has been loaded by running the following ESXCLI command:
~ # esxcli network firewall ruleset list | grep email
email true
Step 4 - Connect to your email server by usingn nc (netcat) by running the following command and specifying the IP Address/Port of your email server:
~ # nc 172.30.0.107 25
220 mail.primp-industries.com ESMTP Postfix
You should recieve a response from your email server and you can enter Ctrl+C to exit. This custom ESXi firewall rule will not persist after a reboot, so you should create a custom VIB to ensure it persists after a system reboot. Please take a look at this article for the details.
To make use of this feature, modify the variable RSYNC_LINK from 0 to 1. Please note, this is an experimental feature request from users that rely on rsync to replicate changes from one datastore volume to another datastore volume. The premise of this feature is to have a standardized folder that rsync can monitor for changes to replicate to another backup datastore. When this feature is enabled, a symbolic link will be generated with the format of "<VMNAME>-symlink" and will reference the latest successful VM backup. You can then rely on this symbolic link to watch for changes and replicate to your backup datastore.
Here is an example of what this would look like:
[root@himalaya ghettoVCB]# ls -la /vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/vcma/
total 0
drwxr-xr-x 1 nobody nobody 110 Sep 27 08:08 .
drwxr-xr-x 1 nobody nobody 17 Sep 16 14:01 ..
lrwxrwxrwx 1 nobody nobody 89 Sep 27 08:08 vcma-symlink -> /vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS/vcma/vcma-2010-09-27_08-07-37
drwxr-xr-x 1 nobody nobody 58 Sep 27 08:04 vcma-2010-09-27_08-04-26
drwxr-xr-x 1 nobody nobody 58 Sep 27 08:06 vcma-2010-09-27_08-05-55
drwxr-xr-x 1 nobody nobody 58 Sep 27 08:08 vcma-2010-09-27_08-07-37
FYI - This feature has not been tested, please provide feedback if this does not work as expected.
To recover a VM that has been processed by ghettoVCB, please take a look at this document: Ghetto Tech Preview - ghettoVCB-restore.sh - Restoring VM's backed up from ghettoVCB to ESX(i) 3.5, ...
There may be a situation where you need to stop the ghettoVCB process and entering Ctrl+C will only kill off the main ghettoVCB process, however there may still be other spawn processes that you may need to identify and stop. Below are two scenarios you may encounter and the process to completely stop all processes related to ghettoVCB.
Step 1 - Press Ctrl+C which will kill off the main ghettoVCB instance
Step 2 - Search for any existing ghettoVCB process by running the following:
# ps -c | grep ghettoVCB | grep -v grep
3360136 3360136 tail tail -f /tmp/ghettoVCB.work/ghettovcb.Cs1M1x
Step 3 - Here we can see there is a tail command that was used in the script. We need to stop this process by using the kill command which accepts the PID (Process ID) which is identified by the first value on the far left hand side of the command. In this example, it is 3360136.
# kill -9 3360136
Note: Make sure you identify the correct PID, else you could accidently impact a running VM or worse your ESXi host.
Step 4 - Depending on where you stopped the ghettoVCB process, you may need to consolidate or remove any existing snapshots that may exist on the VM that was being backed up. You can easily do so by using the vSphere Client.
Step 1 - Search for the ghettoVCB process (you can also validate the PID from the logs)
~ # ps -c | grep ghettoVCB | grep -v grep
3360393 3360393 busybox ash ./ghettoVCB.sh -f list -d debug
3360790 3360790 tail tail -f /tmp/ghettoVCB.work/ghettovcb.deGeB7
Step 2 - Stop both the main ghettoVCB instance & tail command by using the kill command and specifying their respective PID IDs:
kill -9 3360393
kill -9 3360790
Step 3 - If a VM was in the process of being backed up, there is an additional process for the actual vmkfstools copy. You will need to identify the process for that and kill that as well. We will again use ps -c command and search for any vmkfstools that are running:
# ps -c | grep vmkfstools | grep -v grep
3360796 3360796 vmkfstools /sbin/vmkfstools -i /vmfs/volumes/himalaya-temporary/VC-Windows/VC-Windows.vmdk -a lsilogic -d thin /vmfs/volumes/test-dont-use-this-volume/backups/VC-Windows/VC-Windows-2013-01-26_16-45-35/VC-Windows.vmdk
Step 4 - In case there is someone manually running a vmkfstools, make sure you take a look at the command itself and that it maps back to the current VM that was being backed up before kill the process. Once you have identified the proper PID, go ahead and use the kill command:
# kill -9 3360796
Step 5 - Depending on where you stopped the ghettoVCB process, you may need to consolidate or remove any existing snapshots that may exist on the VM that was being backed up. You can easily do so by using the vSphere Client.
Please take a moment to read over what is a cronjob and how to set one up, before continuing
The task of configuring cronjobs on classic ESX servers (with Service Console) is no different than traditional cronjobs on *nix operating systems (this procedure is outlined in the link above). With ESXi on the other hand, additional factors need to be taken into account when setting up cronjobs in the limited shell console called Busybox because changes made do not persist through a system reboot. The following document will outline steps to ensure that cronjob configurations are saved and present upon a reboot.
Important Note: Always redirect the ghettoVCB output to /dev/null and/or to a log when automating via cron, this becomes very important as one user has identified a limited amount of buffer capacity in which once filled, may cause ghettoVCB to stop in the middle of a backup. This primarily only affects users on ESXi, but it is good practice to always redirect the output. Also ensure you are specifying the FULL PATH when referencing the ghettoVCB script, input or log files.
e.g.
0 0 * * 1-5 /vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/ghettoVCB.sh -f /vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/backuplist > /dev/null
or
0 0 * * 1-5 /vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/ghettoVCB.sh -f /vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/backuplist > /tmp/ghettoVCB.log
Task: Configure ghettoVCB.sh to execute a backup five days a week (M-F) at 12AM (midnight) everyday and send output to a unique log file
Configure on ESX:
1. As root, you'll install your cronjob by issuing:
[root@himalaya ~]# crontab -e
2. Append the following entry:
0 0 * * 1-5 /vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/ghettoVCB.sh -f /vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/backuplist > /vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/ghettoVCB-backup-$(date +\%s).log
3. Save and exit
[root@himalaya dlgCore-NFS-bigboi.VM-Backups]# crontab -e
no crontab for root - using an empty one
crontab: installing new crontab
4. List out and verify the cronjob that was just created:
[root@himalaya dlgCore-NFS-bigboi.VM-Backups]# crontab -l
0 0 * * 1-5 /vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/ghettoVCB.sh -f /vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/backuplist > /vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/ghettoVCB-backup-$(date +\%s).log
You're ready to go!
Configure on ESXi:
1. Setup the cronjob by appending the following line to /var/spool/cron/crontabs/root:
0 0 * * 1-5 /vmfs/volumes/simplejack-local-storage/ghettoVCB.sh -f /vmfs/volumes/simplejack-local-storage/backuplist > /vmfs/volumes/simplejack-local-storage/ghettoVCB-backup-$(date +\%s).log
If you are unable to edit/modify /var/spool/cron/crontabs/root, please make a copy and then edit the copy with the changes
cp /var/spool/cron/crontabs/root /var/spool/cron/crontabs/root.backup
Once your changes have been made, then "mv" the backup to the original file. This may occur on ESXi 4.x or 5.x hosts
mv /var/spool/cron/crontabs/root.backup /var/spool/cron/crontabs/root
You can now verify the crontab entry has been updated by using "cat" utility.
2. Kill the current crond (cron daemon) and then restart the crond for the changes to take affect:
On ESXi < 3.5u3
kill $(ps | grep crond | cut -f 1 -d ' ')
On ESXi 3.5u3+
~ # kill $(pidof crond)
~ # crond
On ESXi 4.x/5.0
~ # kill $(cat /var/run/crond.pid)
~ # busybox crond
On ESXi 5.1 to 6.x
~ # kill $(cat /var/run/crond.pid)
~ # crond
On ESXi 7.x
~ # kill $(cat /var/run/crond.pid)
~ # /usr/lib/vmware/busybox/bin/busybox crond
3. Now that the cronjob is ready to go, you need to ensure that this cronjob will persist through a reboot. You'll need to add the following two lines to /etc/rc.local (ensure that the cron entry matches what was defined above). In ESXi 5.1, you will need to edit /etc/rc.local.d/local.sh instead of /etc/rc.local as that is no longer valid.
On ESXi 3.5
/bin/kill $(pidof crond)
/bin/echo "0 0 * * 1-5 /vmfs/volumes/simplejack-local-storage/ghettoVCB.sh -f /vmfs/volumes/simplejack-local-storage/backuplist > /vmfs/volumes/simplejack-local-storage/ghettoVCB-backup-\$(date +\\%s).log" >> /var/spool/cron/crontabs/root
crond
On ESXi 4.x/5.0
/bin/kill $(cat /var/run/crond.pid)
/bin/echo "0 0 * * 1-5 /vmfs/volumes/simplejack-local-storage/ghettoVCB.sh -f /vmfs/volumes/simplejack-local-storage/backuplist > /vmfs/volumes/simplejack-local-storage/ghettoVCB-backup-\$(date +\\%s).log" >> /var/spool/cron/crontabs/root
/bin/busybox crond
On ESXi 5.1 to 6.x
/bin/kill $(cat /var/run/crond.pid)
/bin/echo "0 0 * * 1-5 /vmfs/volumes/simplejack-local-storage/ghettoVCB.sh -f /vmfs/volumes/simplejack-local-storage/backuplist > /vmfs/volumes/simplejack-local-storage/ghettoVCB-backup-\$(date +\\%s).log" >> /var/spool/cron/crontabs/root
crond
On ESXi 7.x
/bin/kill $(cat /var/run/crond.pid) > /dev/null 2>&1
/bin/echo "0 0 * * 1-5 /vmfs/volumes/simplejack-local-storage/ghettoVCB.sh -f /vmfs/volumes/simplejack-local-storage/backuplist > /vmfs/volumes/simplejack-local-storage/ghettoVCB-backup-\$(date +\\%s).log" >> /var/spool/cron/crontabs/root
/usr/lib/vmware/busybox/bin/busybox crond
Afterwards the file should look like the following:
~ # cat /etc/rc.local
#! /bin/ash
export PATH=/sbin:/bin
log() {
echo "$1"
logger init "$1"
}
#execute all service retgistered in /etc/rc.local.d
if [http:// -d /etc/rc.local.d |http:// -d /etc/rc.local.d ]; then
for filename in `find /etc/rc.local.d/ | sort`
do
if [ -f $filename ] && [ -x $filename ]; then
log "running $filename"
$filename
fi
done
fi
/bin/kill $(cat /var/run/crond.pid)
/bin/echo "0 0 * * 1-5 /vmfs/volumes/simplejack-local-storage/ghettoVCB.sh -f /vmfs/volumes/simplejack-local-storage/backuplist > /vmfs/volumes/simplejack-local-storage/ghettoVCB-backup-\$(date +\\%s).log" >> /var/spool/cron/crontabs/root
/bin/busybox crond
This will ensure that the cronjob is re-created upon a reboot of the system through a startup script
2. To ensure that this is saved in the ESXi configuration, we need to manually initiate an ESXi backup by running:
~ # /sbin/auto-backup.sh
config implicitly loaded
local.tgz
etc/vmware/vmkiscsid/vmkiscsid.db
etc/dropbear/dropbear_dss_host_key
etc/dropbear/dropbear_rsa_host_key
etc/opt/vmware/vpxa/vpxa.cfg
etc/opt/vmware/vpxa/dasConfig.xml
etc/sysconfig/network
etc/vmware/hostd/authorization.xml
etc/vmware/hostd/hostsvc.xml
etc/vmware/hostd/pools.xml
etc/vmware/hostd/vmAutoStart.xml
etc/vmware/hostd/vmInventory.xml
etc/vmware/hostd/proxy.xml
etc/vmware/ssl/rui.crt
etc/vmware/ssl/rui.key
etc/vmware/vmkiscsid/initiatorname.iscsi
etc/vmware/vmkiscsid/iscsid.conf
etc/vmware/vmware.lic
etc/vmware/config
etc/vmware/dvsdata.db
etc/vmware/esx.conf
etc/vmware/license.cfg
etc/vmware/locker.conf
etc/vmware/snmp.xml
etc/group
etc/hosts
etc/inetd.conf
etc/rc.local
etc/chkconfig.db
etc/ntp.conf
etc/passwd
etc/random-seed
etc/resolv.conf
etc/shadow
etc/sfcb/repository/root/interop/cim_indicationfilter.idx
etc/sfcb/repository/root/interop/cim_indicationhandlercimxml.idx
etc/sfcb/repository/root/interop/cim_listenerdestinationcimxml.idx
etc/sfcb/repository/root/interop/cim_indicationsubscription.idx
Binary files /etc/vmware/dvsdata.db and /tmp/auto-backup.31345.dir/etc/vmware/dvsdata.db differ
config implicitly loaded
Saving current state in /bootbank
Clock updated.
Time: 20:40:36 Date: 08/14/2009 UTC
Now you're really done!
If you're still having trouble getting the cronjob to work, ensure that you've specified the correct parameters and there aren’t any typos in any part of the syntax.
Ensure crond (cron daemon) is running:
ESX 3.x/4.0:
[root@himalaya dlgCore-NFS-bigboi.VM-Backups]# ps -ef | grep crond | grep -v grep
root 2625 1 0 Aug13 ? 00:00:00 crond
ESXi 3.x/4.x/5.x:
~ # ps | grep crond | grep -v grep
5196 5196 busybox crond
Ensure that the date/time on your ESX(i) host is setup correctly:
ESX(i):
[root@himalaya dlgCore-NFS-bigboi.VM-Backups]# date
Fri Aug 14 23:44:47 PDT 2009
Note: Careful attention must be noted if more than one backup is performed per day. Backup windows should be staggered to avoid contention or saturation of resources during these periods.
0Q: I'm getting error X when using the script or I'm not getting any errors, the backup didn’t even take place. What can I do?
0A: First off, before posting a comment/question, please thoroughly read through the ENTIRE documentation including the FAQs to see if your question has already been ansered.
1Q: I've read through the entire documentation + FAQs and still have not found my answer to the problem I'm seeing. What can I do?
1A: Please join the ghettoVCB Group to post your question/comment.
2Q: I've sent you private message or email but I haven't received a response? What gives?
2A: I do not accept issues/bugs reported via PM or email, I will reply back, directing you to post on the appropriate VMTN forum (that's what it's for). If the data/results you're providing is truely senstive to your environment I will hear you out, but 99.99% it is not, so please do not messsage/email me directly. I do monitor all forums that contain my script including the normal VMTN forums and will try to get back to your question as soon as I can and as time permits. Please do be patient as you're not the only person using the script (600,000+ views), thank you.
3Q: Can I schedule backups to take place hourly, daily, monthly, yearly?
3A: Yes, do a search online for crontab.
4Q: I would like to setup cronjob for ESX(i) 3.5 or 4.0?
4A: Take a look at the Cronjob FAQ section in this document.
5Q: I want to schedule my backup on Windows, how do I do this?
5A: Do a search for plink. Make sure you have paired SSH keys setup between your Windows system and ESX/ESXi host.
6Q: I only have a single ESXi host. I want to take backups and store them somewhere else. The problem is: I don't have NFS, iSCSI nor FC SAN. What can I do?
6A: You can use local storage to store your backups assuming that you have enough space on the destination datastore. Afterwards, you can use scp (WinSCP/FastSCP) to transfer the backups from the ESXi host to your local desktop.
7Q: I’m pissed; the backup is taking too long. My datastore is of type X?
7A: YMMV, take a look at your storage configuration and make sure it is optimized.
8Q: I noticed that the backup rotation is occurring after a backup. I don't have enough local storage space, can the process be changed?
8A: This is primarily done to ensure that you have at least one good backup in case the new backup fails. If you would like to modify the script, you're more than welcome to do so.
9Q: What is the best storage configuration for datastore type X?
9A: Search the VMTN forums; there are various configurations for the different type of storage/etc.
10Q: I want to setup an NFS server to run my backups. Which is the best and should it be virtual or physical?
10A: Please refer to answer 7A. From experience, we’ve seen physical instances of NFS servers to be faster than their virtual counterparts. As always, YMMV.
11Q: I have VMs that have snapshots. I want to back these things up but the script doesn’t let me do it. How do I fix that?
11A: VM snapshots are not meant to be kept for long durations. When backing up a VM that contains a snapshot, you should ensure all snapshots have been committed prior to running a backup. No exceptions will be made…ever.
12Q: I would like to restore from backup, what is the best method?
12A: The restore process will be unique for each environment and should be determined by your backup/recovery plans. At a high level you have the option of mounting the backup datastore and registering the VM in question or copy the VM from the backup datastore to the ESX/ESXi host. The latter is recommended so that you're not running a VM living on the backup datastore or inadvertently modifying your backup VM(s). You can also take a look at ghettoVCB-restore which is experimentally supported.
13Q: When I try to run the script I get: "-bash: ./ghettoVCB.sh: Permission denied", what is wrong?
13A: You need to change the permission on the script to be executable, chmod +x ghettoVCB.sh
14Q: Where can I download the latest version of the script?
14A: The latest version is available on on github - https://github.com/lamw/ghettoVCB/downloads
15Q: I would like to suggest/recommend feature X, can I get it? When can I get it? Why isn't it here, what gives?
15A: The general purpose of this script is to provide a backup solution around VMware VMs. Any additional features outside of that process will be taken into consideration depending on the amount of time, number of requests and actual usefulness as a whole to the community rather than to an individual.
16Q: I have found this script to be very useful and would like to contribute back, what can I do?
16A: To continue to develop and share new scripts and resources with the community, we need your support. You can donate here Thank You!
17Q: What are the different type of backup uses cases that are supported with ghettoVCB?
17A: 1) Live backup of VM with the use of a snapshot and 2) Offline backup of a VM without a snapshot. These are the only two use cases supported by the script.
18Q: When I execute the script on ESX(i) I get some funky errors such as ": not found.sh" or "command not found". What is this?
18A: Most likely you have some ^M characters within the script which may have come from either editing the script using Windows editor, uploading the script using the datastore browser OR using wget. The best option is to either using WinSCP on Windows to upload the script and edit using vi editor on ESX(i) host OR Linux/UNIX scp to copy the script into the host. If you still continue to have the issue, do a search online on various methods of removing this Windows return carriage from the script
19Q: My backup works fine OR it works for a single backup but I get an error message "Input/output error" or "-ash: YYYY-MM-DD: not found" during the snapshot removal process. What is this?
19A: The issue has been recently identified by few users as a problem with user's NFS server in which it reports an error when deleting large files that take longer than 10seconds. VMware has recently released a KB article http://kb.vmware.com/kb/1035332 explaining the details and starting with vSphere 4.1 Update 2 or vSphere 5.0, a new advanced ESX(i) parameter has been introduced to increase the timeout. This has resolved the problem for several users and maybe something to consider if you are running into this issue, specifically with NFS based backups.
20Q: Will this script function with vCenter and DRS enabled?
20Q: No, if the ESX(i) hosts are in a DRS enabled cluster, VMs that are to be backed up could potentially be backed up twice or never get backed up. The script is executed on a per host basis and one would need to come up a way of tracking backups on all hosts and perhaps write out to external file to ensure that all VMs are backed up. The main use case for this script are for standalone ESX(i) host
21Q: I'm trying to use WinSCP to manually copy VM files but it's very slow or never completes on huge files, why is that?
21A: WinSCP was not designed for copying VM files out of your ESX(i) host, take a look at Veeam's FastSCP which is designed for moving VM files and is a free utility.
22Q: Can I use setup NFS Server using Windows Services for UNIX (WSFU) and will it work?
22A: I've only heard a handful of users that have successfully implemented WSFU and got it working, YMMV. VMware also has a KB article decribing the setup process here: http://kb.vmware.com/kb/1004490 for those that are interested. Here is a thread on a user's experience between Windows Vs. Linux NFS that maybe helpful.
23Q: How do VMware Snapshots work?
23A: http://kb.vmware.com/kb/1015180
24Q: What files make up a Virtual Machine?
24A: http://virtualisedreality.wordpress.com/2009/09/16/quick-reminder-of-what-files-make-up-a-virtual-ma...
25Q: I'm having some issues restoring a compressed VM backup?
25A: There is a limitation in the size of the VM for compression under ESXi 3.x & 4.x, this limitation is in the unsupported Busybox console and should not affect classic ESX 3.x/4.x. On ESXi 3.x, the maximum largest supported VM is 4GB for compression and on ESXi 4.x the largest supported VM is 8GB. If you try to compress a larger VM, you may run into issues when trying to extract upon a restore. PLEASE TEST THE RESTORE PROCESS BEFORE MOVING TO PRODUCTION SYSTEMS!
26Q: I'm backing up my VM as "thin" format but I'm still not noticing any size reduction in the backup? What gives?
2bA: Please refer to this blog post which explains what's going on: http://www.yellow-bricks.com/2009/07/31/storage-vmotion-and-moving-to-a-thin-provisioned-disk/
27Q: I've enabled VM_SNAPSHOT_MEMORY and when I restore my VM it's still offline, I thought this would keep it's memory state?
27A: VM_SNAPSHOT_MEMORY is only used to ensure when the snapshot is taken, it's memory contents are also captured. This is only relavent to the actual snapshot itself and it's not used in any shape/way/form in regards to the backup. All backups taken whether your VM is running or offline will result in an offline VM backup when you restore. This was originally added for debugging purposes and in generally should be left disabled
28Q: Can I rename the directories and the VMs after a VM has been backed up?
28A: The answer yes, you can ... but you may run into all sorts of issues which may break the backup process. The script expects a certain layout and specific naming scheme for it to maintain the proper rotation count. If you need to move or rename a VM, please take it out of the directory and place it in another location
29Q: Can ghettoVCB support CBT (Change Block Tracking)?
29A: No, that is a functionality of the vSphere API + VDDK API (vSphere Disk Development Kit). You will need to look at paid solutions such as VMware vDR, Veeam Backup & Recovery, PHD Virtual Backups, etc. to leverage that functionailty.
30Q: Does ghettoVCB support rsync backups?
30A: Currently ghettoVCB does not support rsync backups, you either obtain or compile your own static rsync binary and run on ESXi, but this is an unsupported configuration. You may take a look at this blog post for some details.
31Q: How can I contribute back?
31A: You can provide feedback/comments on the ghettoVCB Group. If you have found this script to be useful and would like to contribute back, please click here to donate.
32Q: How can select individual VMDKs to backup from a VM?
32A: Ideally you would use the "-c" option which requires you to create individual VM configuration file, this is where you would select specific VMDKs to backup. Note, that if you do not need to define all properties, anything not defined will adhere from the default global properties whether you're editing the ghettoVCB.sh script or using ghettoVCB global configuration file. It is not recommended that you edit the ghettoVCB.sh script and modify the VMDK_FILES_TO_BACKUP variable, but if you would like to keep everything in one script, you may add the extensive list of VMDKs to backup but do know this can get error prone as script may be edited frequently and lose some flexibility to support multiple environments.
33Q: Why is email not working when I'm using ESXi 5.x but it worked in ESXi 4.x?
33A: ESXi 5.x has implemented a new firewall which requires the email port that is being used to be opened. Please refer to the following articles on creating a custom firewall rule for email:
http://www.virtuallyghetto.com/2012/09/creating-custom-vibs-for-esxi-50-51.html
How to Create Custom Firewall Rules in ESXi 50
How to Persist Configuration Changes in ESXi 4.x/5.x Part 1
How to Persist Configuration Changes in ESXi 4.x/5.x Part 2
34Q: How do I stop the ghettoVCB process?
34A: Take a look at the Stopping ghettoVCB Process section of the documentation for more details.
Many have asked what is the best configuration and recommendation for setting up a cheap NFS Server to run backups for VMs. This has been a question we've tried to stay away from just because the possiblities and solutions are endless. One can go with physical vs. virtual, use VSA (Virtual Storage Appliances) such as OpenFiler or Lefthand Networks, Windows vs. Linux/UNIX. We've not personally tested and verify all these solutions and it all comes down to "it depends" type of answer. Though from our experience, we've had much better success with a physical server than a virtual.
It is also well known that some users are experiencing backup issues when running specifically against NFS, primarily around the rotation and purging of previous backups. The theory from what we can tell by talking to various users is that when the rotation is occuring, the request to delete the file(s) may take awhile and does not return within a certain time frame and causes the script to error out with unexpected messages. Though the backups were successful, it will cause unexpected results with directory structures on the NFS target. We've not been able to isolate why this is occuring and maybe due to NFS configuration/exports or hardware or connection not being able to support this process.
We'll continue to help where we can in diagonising this issus but we wanted to share our current NFS configuration, perhaps it may help some users who are new or trying to setup their system. ( Disclaimer: These configurations are not recommendations nor endorsement for any of the components being used)
UPDATE: Please also read FAQ #19 for details + resolution
Server Type: Physical
Model: HP DL320 G2
OS: Arch linux 2.6.28
Disks: 2 x 1.5TB
RAID: Software RAID1
Source Host Backups: ESX 3.5u4 and ESX 4.0u1 (We don't run any ESXi hosts)
uname -a output
Linux XXXXX.XXXXX.ucsb.edu 2.6.28-ARCH #1 SMP PREEMPT Sun Jan 18 20:17:17 UTC 2009 i686 Intel(R) Pentium(R) 4 CPU 3.06GHz GenuineIntel GNU/Linux
NICs:
00:05.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5702X Gigabit Ethernet (rev 02)
00:06.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5702X Gigabit Ethernet (rev 02)
NFS Export Options:
/exports/vm-backups XXX.XXX.XXX.XXX/24(rw,async,all_squash,anonuid=99,anongid=99)
*One important thing to check is to verify that your NFS exportion options are setup correctly, "async" should be configured to ensure that all IO requests are processed and reply back to the client before waiting for the data to be written to the storage.
*Recently VMware released a KB article describing the various "Advanced NFS Options" and their meanings and recommendations: http://kb.vmware.com/kb/1007909 We've not personally had to touch any of these, but for other vendors such as EMC and NetApp, there are some best practices around configuring some of these values depending on the number of NFS volumes or number of ESX(i) host connecting to a volume. You may want to take a look to see if any of these options may help with NFS issue that some are seeing
*Users should also try to look at their ESX(i) host logs during the time interval when they're noticing these issues and see if they can find any correlation along with monitoring the performance on their NFS Server.
*Lastly, there are probably other things that can be done to improve NFS performance or further optimization, a simple search online will also yield many resources.
Windows utility to email ghettoVCB Backup Logs - http://www.waldrondigital.com/2010/05/11/ghettovcb-e-mail-rotate-logs-batch-file-for-vmware/
Windows front-end utility to ghettoVCB - http://www.magikmon.com/mkbackup/ghettovcb.en.html
Note: Neither of these tools are supported, for questions or comments regarding these utilities please refer to the author's pages.
Enhancements:
Fixes:
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Enhancements:
Fixes:
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Enhancements:
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Enhancements:
Fixes:
Enhancements:
Fixes:
Big thanks to Alain Spineux and his contributions to the ghettoVCB script and helping with debugging and testing.
Enhancements:
Fixes:
Enhancements:
Enhancements:
Enhancements:
Fixes:
Fixes:
Enhancements:
Fixes:
Fixes:
Big thanks goes out to the community for the suggested features and to those that submitted snippet of their modifications.
Updated FAQ #20-24 for common issues/questions. Also included a new section about our "personal" NFS configuration and setup.
Fix the crontab section to reflect the correct syntax + updated FAQ #17,#18 and #19 for common issues.
The following enhancements and fixes have been implemented in this release of ghettoVCB. Special thanks goes out to all the ghettoVCB BETA testers for providing time and their environments to test features/fixes of the new script!
Enhancements:
Fixes:
Hello everybody,
I am trying to do the backup of a esxi with this script, it is working perfecty, but I need to backup the vm´s with rdp too.
I have tried the ghettoVCBg2.pl without success.
Anybody has the code to add to the script to backup the vm´s ignoring the rdp?
Thanks a lot for yor help!
Regards.
Jose
Same problems with cdroms and same solution of "shechtl".
I have to delete the cdrom on some VM to complete the backup
Hello,
In terms of the strange path pointing to an ISO file I had the same behaviour and after removing all mounted CD on all VM's it was gone.
My experience about the "DiskLib_Check() failed for source disk" error message in a ESXi3.5 environment is that the error is caused when the backup loop in the script executes "vmkfstools -i "$" "$".
During first cycle in the loop of a new VM the Source_VMDK and Destination_VMDK do not point to files, they point to folders and this is causing not supported by the vmkfstools. I am not a shell developer but this is how it looks to me.
By the way somethign interesting.
On a ESXi4 using the ghettoVCB4i.sh I noticed that a "DiskLib_Check() failed for source disk" error is only shown if the VM config file has been created as a version 7. All VM's version 4 can be backed up without the error to pop up.
Hi.
I just upgraded the scripts for 4.0 and get this error on one of 2 VM one the box.
RDM was found for 14_MSCLink_TestOS_Win2k8, backup will not take place
ah.
Found the comment at the begining of the doc.
Sorry!
BTW, the VM has 2 disks, one virtual and one RAW. Is there a way to backup the virtual one?¿
Hi everyone, I've just pushed out an update to both ghettoVCB.sh and ghettoVCB4i which should fix the issue with the script trying to backup .iso when you have a mounted CD-ROM, this should not be an issue anymore and supports backing up w/o having to remove the CD-ROM device.
I've also added 2 additional VMDK output format and added a new variable to support the various types:
# Format output of VMDK backup # 1 = zeroedthick # 2 = 2gbsparse # 3 = thin # 4 = eagerzeroedthick VMDK_OUTPUT_FORMAT=1
Please take a look at the change log for more details (07/19/09) and if you're interested in any type of logging, there is a new section at the top for Advanced Logging.
Please download the latest scripts and let me know if you're still running into the .iso issues.
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
I am running this script with VMWare ESXi 3.5 and it works great. Well almost. One of my VMs is a Linux based file server that has a small vmdk for itself, and also uses NFS mounted disk storage for the bulk of its storage. I only want the local vmdk to be backed up in this case. Is there a way, on a per VM basis, that you can set preferences to only backup the local vmdk of a vm with this script if there are remote storage (NFS or iSCSI) for the vm that you don't want backed up?
Hope that makes sense.
Myles
Not a supported feature of the script, you're more than welcome to modify to fit your needs or create separate backup jobs. Remember, the script itself is providing a generic backup solution, if you need something more specific you'll need to make those changes.
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
I can certainly create separate backup jobs for this particular VM, but if I understand the way this works, I'd have to not only create a separate file with the target VM to backup, but I'd also have to create a modified ghettoVCB.sh script to tell it to only backup the specified vmdk files, right? That's ok, but it obviously requires a programming change in the way that the script determines what to backup by VM. Just before I launch down that path (which I'm fine with doing), I just wanted to make sure that there wasn't a preference property already available in the standard ghettoVCB.sh script that would cater for this...
Myles
Yes, you'll need to add some type of logic to on figuring out which VMDKs to backup and not backup and have a way to specify that in either a local configuration file stored within each VM or a config file read into the script. There's nothing in the script today that supports the request you're talking about, good luck.
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
Hello,
Can anyone tell me best way to determine a ghettoVCB backup is running on a ESXi?
Beside this what is the best way to stop a backup process and how do I have to performe this?
I do not have any problems with the scripts so far, but would like to know how to kill things without messing up my whole ESXi.
Thanks in advance for a reply.
maweko
To check if the process is running, from ssh:
ps|grep ghettoVCB.sh
To kill the process:
kill -9 id_from_above
If you kill it, remember to manually remove snapshots using VirtualCenter or whatever you use, don't delete snapshot files by hand.
Thank's for the info.
Tested it on my ESXi 3.5 U4 and although a backup process is actually running the ps does not display any process with name "ghettoVCB.sh" .
That's a bit confusing.
I started the backup with ./ghettoVCB.sh "vmlist file"
Any ideas
I've tested the new version of the script. I try to create thin format for the backup. But although it creates flat format vmdk's. Where could be problem?
thanks in advance for a reply.
Adrian
I think "thin" provisioning for post vSphere ESX(i) 4.0 may not act in the way people expect, I certainly haven't played with thin provisioning too much. I need you to do the following two things:
1) What is the script configured to, meaning what value did you set the VMDK_OUTPUT_FORMAT, default is 1 which is zeroedthick
2) On the VM that was backed up thin, can you go into the folder and cat out the .vmdk file and NOT the *-flat.vmdk
3) When running the backup, can you do it manually and see if you see a screen output similar to this:
~ # ./ghettoVCB4i.sh vmbackuplist ################ Taking backup snapshot for ghettoVCB4i-test-vm-backup ... ################ Destination disk format: VMFS thin-provisioned Cloning disk '/vmfs/volumes/datastore1/ghettoVCB4i-test-vm-backup/ghettoVCB4i-test-vm-backup.vmdk'... Clone: 100% done. Removing snapshot from ghettoVCB4i-test-vm-backup ... #################### Completed backup for ghettoVCB4i-test-vm-backup! ####################
Specifically you're looking for the key words "Destination disk format: VMFS thin-provisioned", if so, then thin provisioning is occurring and this goes back to my initial thought on how thin provisioning may work in ESX(i) 3.5. Remember by default if you backup to NFS datastore, it 'should' be thin by default whether or not you select it from vmkfstools, least from my own experiences.
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
Hi Lamw,
I changed now to your new version with the cdrom fix. It works with most of our machines, but there is one vm where I got problems.
Its the only VM with Win98 and a ide hdd (I know Win98 but its a must)
If I start the script, the scripts makes a snapshot and removes the snapshot after that immediately, but no disks will be copied.
I think the problem is ide. With the old version backup is running but only without the cdrom.
Here is the relevant part of the log:
+ IFS=
+ echo ide0:0
+ SCSI_ID=ide0:0
+ grep -i ide0:0.present /vmfs/volumes/iscsi2dsa1/samwin/samwin.vmx
+ grep -i true
+ grep -i ide0:0.deviceType /vmfs/volumes/iscsi2dsa1/samwin/samwin.vmx
+ grep -i scsi-hardDisk
+ IFS=
+ vim-cmd vmsvc/power.getstate 224
+ tail -1
+ ORGINAL_VM_POWER_STATE=Powered on
+ [[ ! 0 -eq 1 ]]
+ [[ Powered on != Powered off ]]
+ echo ################ Taking backup snapshot for samwin ... ################
+ date +%F
+ vim-cmd vmsvc/snapshot.create 224 vcb_snap VCB_BACKUP_samwin_2009-07-21
+ OLD_IFS=
+ IFS=:
+ IFS=
+ [[ ! 0 -eq 1 ]]
+ [[ Powered on == Powered on ]]
+ vim-cmd vmsvc/snapshot.remove 224
+ echo Removing snapshot from samwin ...
Removing snapshot from samwin ...
+ ls /vmfs/volumes/iscsi2dsa1/samwin
+ grep -q delta
ls: /vmfs/volumes/iscsi2dsa1/samwin/samwin-000001.vmdk.lck: No such file or directory
+ sleep 3
+ ls /vmfs/volumes/iscsi2dsa1/samwin
+ grep -q delta
+ [[ 0 -eq 1 ]]
+ TMP_IFS=
Hope you could help
Okay, I see the issue. This should hopefully be fixed now in the latest version of the script. Give it a run and let me know how it goes.
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
/vmfs/volumes/4965afe0-76fbdae2-48e3-00221952c5db # ls
ANTHEAFILESThin PieraVMThin TimbratureVMThin
ANTHEAR10TEST R10INTERNO ghettoVCB4i.sh
AntheaDom R9SVP weekly
IvanoVMThin RosalbaVMVistaThin weekly2
/vmfs/volumes/4965afe0-76fbdae2-48e3-00221952c5db # sh ghettoVCB4i.sh weekly2
Taking backup snapshot for IvanoVMThin ... ################
Destination disk format: VMFS zeroedthick
Cloning disk '/vmfs/volumes/datastore1/IvanoVMThin/IvanoVMThin.vmdk'...
Clone: 100% done.
Removing snapshot from IvanoVMThin ...
sh: /vmfs/volumes/VMBACKUP/ESX22/IvanoVMThin/IvanoVMThin-2009-07-21: bad number
ghettoVCB4i.sh: line 374: syntax error: /vmfs/volumes/VMBACKUP/ESX22/IvanoVMThin/IvanoVMThin-2009-07-21+1
/vmfs/volumes/4965afe0-76fbdae2-48e3-00221952c5db #
I receive always this error when I backup this thin VM with windows XP.
Can someone help me?
Are you using the latest version of the script? Also if you have the right permissions set, you don't need to execute with "sh", you should do something like this:
./ghettoVCB4i.sh weekly2
Also there is a param in the script after the "DO NOT EDIT" portion that provides some debugging information called "DEVEL_MODE" can you please change this from 0 to 1 and re-run the script and provide the output of that. To ensure the forum does not mangle your screen output, please wrap it in tags
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
First of all, thanks to all who have had a part putting this script together. I'm very new to VMWare and Linux, and this has all been such a huge help. However, I'm having the same issue as adiXSG. I have a Linux VM that I have given a thin disk, and I have uploaded the most recent version of the ghettoVCB4i.sh script, choosing option 3 for thin disk format. However, the output is "servername-flat.vmdk" and the file size is 100 gigs, not the 5.2 or so gigs that it should be (the size of the original thin .vmdk file).
I hope I'm describing this properly, does anyone know what the problem could be? Thanks!
Please take a look at this response http://communities.vmware.com/docs/DOC-8760#comments-11794 and provide the requested output
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
I'm running the latest version of the script. I tried with ./ghetto..... but the problem remain.
The file have the rights "rwxr-xr-x"
If I change DEVEL_MODE I receive this information
/vmfs/volumes/4965afe0-76fbdae2-48e3-00221952c5db # ./ghettoVCB4i.sh weekly2
(vim.fault.DuplicateName) {
dynamicType = ,
faultCause = (vmodl.MethodFault) null,
name = "VMBACKUP",
object = 'vim.Datastore:192.168.111.23:/VMBACKUP',
msg = "The name 'VMBACKUP' already exists.",
}
##########################################
Virtual Machine: IvanoVMThin
VM_ID: 448
VMX_PATH: /vmfs/volumes/datastore1/IvanoVMThin/IvanoVMThin.vmx
VMX_DIR: /vmfs/volumes/datastore1/IvanoVMThin
VMX_CONF: IvanoVMThin/IvanoVMThin.vmx
VMFS_VOLUME: datastore1
##########################################
##########################################
Virtual Machine: PieraVMThin
VM_ID: 432
VMX_PATH: /vmfs/volumes/datastore1/PieraVMThin/PieraVMThin.vmx
VMX_DIR: /vmfs/volumes/datastore1/PieraVMThin
VMX_CONF: PieraVMThin/PieraVMThin.vmx
VMFS_VOLUME: datastore1
##########################################
##########################################
Virtual Machine: TimbratureVMThin
VM_ID: 400
VMX_PATH: /vmfs/volumes/datastore1/TimbratureVMThin/TimbratureVMThin.vmx
VMX_DIR: /vmfs/volumes/datastore1/TimbratureVMThin
VMX_CONF: TimbratureVMThin/TimbratureVMThin.vmx
VMFS_VOLUME: datastore1
##########################################
##########################################
Virtual Machine: RosalbaVMVistaThin
VM_ID: 416
VMX_PATH: /vmfs/volumes/datastore1/RosalbaVMVistaThin/RosalbaVMVistaThin.vmx
VMX_DIR: /vmfs/volumes/datastore1/RosalbaVMVistaThin
VMX_CONF: RosalbaVMVistaThin/RosalbaVMVistaThin.vmx
VMFS_VOLUME: datastore1
##########################################
Start time: Thu Jul 23 06:16:31 UTC 2009
End time: Thu Jul 23 06:16:34 UTC 2009
Duration : 3 Seconds
DEVEL MODE OUTPUT COMPLETE
/vmfs/volumes/4965afe0-76fbdae2-48e3-00221952c5db #
I don't see anything wrong from the output, is this the only VM you're having problems with? Can you ensure there are no left over snapshots from the script?
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
Ok, I hope I'm being clear, please let me know if you need clarification:
1) For VMDK_OUTPUT_FORMAT, I set the value to 3 for thin disk
2) I'm not sure what you mean by this. Can you provide instructions on how to "cat out" the .vmdk file? I do see two vmdk files, one is the -flat file (100 gigs) the other is servername.vmdk but is only 1k.
3) When running the script, I do see that output and the line "Destination disk format: VMFS thin-provisioned"
I also was able to clone the disk manually using the following command, which appears in the ghettoVCB4i.sh script:
#vmkfstools -i /vmfs/volumes/san_vmfs/my_vm/large_disk.vmdk -d thin /vmfs/volumes/san_vmfs/my_vm/new_thin_disk.vmdk
That command worked in converting the vmdk to a thin disk, so I'm not sure why the script isn't.
I'm sure no snapshot on the VM.
I have the same problem on another VM with different OS.
The backup process seems to work fine. Infact it arrive at 100% and the file created seems correct.
Maybe the problem is when try to cancel the old folder backup or the snapshot.
I've spent the past 2 hours or so reading through this thread from start to finish!! Incredibly valuable help from all!
However, I have a few questions that I feel have not been asked/answered.
1. I access my ESXi host remotely with HP iLO via VPN. Am I correct in saying that I can copy the script from my remote system to the ESXi system WITHOUT enabling the unsupported mode and/or SSH if I use vCLI with command vifs?
2. Maybe I have missed something, but where do you actually store the ghettoVCB script? It seems that you can choose to store it on external or internal storage. I am interested in internal, but where is the appropriate location?
3. I understand that most users are starting the script from another system via SSH. This is well explained, but I am interested in scheduling the script from within the ESXi host. Now there are a few references to crontab (new to me) and some suggestions on how to set this up. Some say edit rc.local and others are doing something like this
*echo "0 2 * * 6 /vmfs/volumes/vmiscsi/tools/ghettoVCB4i.sh" > /var/spool/cron/crontabs/root*
However, the different approaches have me confused, so William could you please add a section at the top with the "best practice" of configuring a crontab to run the script or post a recommendation?
Thanks for an excellent free backup solution!!
voro can you please elaborate on how to push ESXi logs to a syslog server and what the advantages are (I'm new to this)? I found a virtual appliance http://www.syslogappliance.de/en/ would this work if it resides on the same ESXi host?
Thanks
3) If you want to schedule it without keeping a ssh session open or using a remote system, you have to use ESXi's crond. Busybox's crond is limited and adding that line in /var/spool/cron/crontabs/root is the only way, but it will be lost upon rebot. That's why some suggest adding that echo in rc.local
About Remote logging
Advantages:
Easier manageability, you don't need to keep the VIClient/VCenter open to read the logs, you can parse them with third party tools/custom scripts, you don't lose them if something goes wrong, you can setup alerts if certain entry is logged,etc. There are dozens of reasons, just google it.
Howto:
Very easy. Log to local syslog running the script as I posted before
./ghettoVCB4i.sh vmbackuplist 2>&1 | busybox logger -t ghettoVCB4i -p 1
then, configure ESXi's syslog to log to a remote host
vi /etc/syslog.conf
or with VIClient configuration tab (it's in advanced features), just add remote syslog's IP or hostname.
Configuring remote daemon can be as easy as doing nothing (depends on your defaults) or allowing ESXi's to push their logs there, or even using a separate file to store those logs (easier with syslog-ng)
It doesn't matter if it's another VM on the same host, a physical computer or even a server on a different network as long as ESXi can reach UDP Port 514 on the remote syslog.
When looking at the actual size of thin provisioned disk, if you do 'ls -lha', it will not show you the actual disk consumption. So by running the conversion in a script or from the CLI, it should yield the same results. Are you sure you're using the same VM and doing one backup and then doing it from the CLI to ensure you're looking at the same VM? You'll be able to see the actual consumption if you do something like 'du -h' since ESXi unsupported console does not have 'du' nor 'vdf'.
Here is an example:
I have a VM that is allocated thick with 8gb:
/vmfs/volumes/4a59c382-f2feee8e-0280-005056825b84/ide-vm # ls -Falh drwxr-xr-x 1 root root 980 Jul 25 12:06 ./ drwxr-xr-t 1 root root 1.2k Jul 25 12:03 ../ -rw------- 1 root root 8.0G Jul 21 19:36 ide-vm-flat.vmdk -rw------- 1 root root 440 Jul 21 19:36 ide-vm.vmdk -rw------- 1 root root 0 Jul 21 19:36 ide-vm.vmsd -rwxr-xr-x 1 root root 1.5k Jul 21 19:36 ide-vm.vmx* -rw------- 1 root root 261 Jul 21 19:36 ide-vm.vmxf
I have a local datastore that has 5.6G free, which is where this specific VM is stored and where the backup will go (vmfs3 is the local storage):
/vmfs/volumes/4a59c382-f2feee8e-0280-005056825b84/ide-vm # df -h Filesystem Size Used Available Use% Mounted on visorfs 278.2M 243.3M 34.9M 87% / nfs 1.3T 789.7G 558.7G 59% /vmfs/volumes/d32c5a97-e039bdbf vfat 4.0G 384.0k 4.0G 0% /vmfs/volumes/4a59c381-8059e09f-33a3-005056825b84 vfat 249.7M 76.2M 173.5M 31% /vmfs/volumes/7db9337b-a328f52c-2a05-87d4ed7807df vfat 249.7M 4.0k 249.7M 0% /vmfs/volumes/eb676f73-6dd0961e-3224-09791e2c7199 vfat 285.9M 230.2M 55.7M 81% /vmfs/volumes/c2a427e4-2d317086-fef9-b5750d88536c vmfs3 15.0G 9.4G 5.6G 62% /vmfs/volumes/4a59c382-f2feee8e-0280-005056825b84
I know manually clone on the CLI:
/vmfs/volumes/4a59c382-f2feee8e-0280-005056825b84/ide-vm # vmkfstools -i ide-vm.vmdk -d thin ide-vm-THIN.vmdk Destination disk format: VMFS thin-provisioned Cloning disk 'ide-vm.vmdk'... Clone: 100% done.
As you can see from the above, it thinly provisioned and it was done VERY quickly and now lets take a look at the directory listing to see what 'ls' shows us:
/vmfs/volumes/4a59c382-f2feee8e-0280-005056825b84/ide-vm # ls -Falh drwxr-xr-x 1 root root 1.2k Jul 25 12:08 ./ drwxr-xr-t 1 root root 1.2k Jul 25 12:03 ../ -rw------- 1 root root 8.0G Jul 25 12:08 ide-vm-THIN-flat.vmdk -rw------- 1 root root 494 Jul 25 12:08 ide-vm-THIN.vmdk -rw------- 1 root root 8.0G Jul 21 19:36 ide-vm-flat.vmdk -rw------- 1 root root 440 Jul 21 19:36 ide-vm.vmdk -rw------- 1 root root 0 Jul 21 19:36 ide-vm.vmsd -rwxr-xr-x 1 root root 1.5k Jul 21 19:36 ide-vm.vmx* -rw------- 1 root root 261 Jul 21 19:36 ide-vm.vmxf
Both the original and thin clone still shows up 8gb, but if you look at 'df' you'll notice that available space is still 5.6gb, meaning the disk was thin provisioned else I would have ran out of space:
/vmfs/volumes/4a59c382-f2feee8e-0280-005056825b84/ide-vm # df -h Filesystem Size Used Available Use% Mounted on visorfs 278.2M 243.3M 34.9M 87% / nfs 1.3T 789.7G 558.7G 59% /vmfs/volumes/d32c5a97-e039bdbf vfat 4.0G 384.0k 4.0G 0% /vmfs/volumes/4a59c381-8059e09f-33a3-005056825b84 vfat 249.7M 76.2M 173.5M 31% /vmfs/volumes/7db9337b-a328f52c-2a05-87d4ed7807df vfat 249.7M 4.0k 249.7M 0% /vmfs/volumes/eb676f73-6dd0961e-3224-09791e2c7199 vfat 285.9M 230.2M 55.7M 81% /vmfs/volumes/c2a427e4-2d317086-fef9-b5750d88536c vmfs3 15.0G 9.4G 5.6G 62% /vmfs/volumes/4a59c382-f2feee8e-0280-005056825b84
Just to prove that this case, I try to do a standard clone which by default is zeroedthick which fails:
/vmfs/volumes/4a59c382-f2feee8e-0280-005056825b84/ide-vm # vmkfstools -i ide-vm.vmdk ide-vm-THICK.vmdk Destination disk format: VMFS zeroedthick Cloning disk 'ide-vm.vmdk'... Failed to clone disk : There is not enough space on the file system for the selected operation (13).
So the script is indeed doing what you're setting it up to and you probably were looking at the wrong file when comparing the disk usage as there is a -flat.vmdk which is the actual vDisk and the .vmdk which is the descriptor file for a given VM.
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
Question: I know that ghettoVCB.sh will skip a backup if any snapshots exist. We have a couple of ESXi servers that we never use snapshots on. Is there any danger in modifying the script to forcibly remove any snapshots with the script if it finds any and then do the backups? I know that the script can remove snapshots - I just don't want backups skipped if they were attempted before, and the script failed for some reason, leaving the VMs in a state where they can be never backed up afterwards unless there is some manual intervention to remove the snapshots.
Myles
The script should always remove all snapshots that 'it' creates so long as you don't intervene or manually tweak with a VM during the backup process. I'm not exactly sure what you mean your initial statement, of ESXi servers that never use snapshots. The backup process requires snapshots as you know OR you have the option of powering off the VM before backup. If you're worried for some reason that snapshots may be left behind for whatever reason, you of course could modify the script in such a way to loop through all VMs and removeallsnapshots, but you will receive no support if you do make such modifications. If you follow all requirements and you've verified before implementing ghettoVCB, you should not have any issues with VMs having snapshots in the first place and they should all be removed prior to moving to the next VM.
Hopefully this cleared up your concerns, also if this was an issue, I'm sure I would have heard from many others about it
Thanks again.
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
Hmm, are my questions too trivial that no one wants to respond? I'm not asking just for the sake of it. There are many repeat questions/ answers not just here, but on any forum. However, like I said I have gone through this thread diligently and I couldn't find answers to what may be simple questions. I'm sure others would benefit.
Well, I look forward to some response, so I can better understand how to use this. Thanks
1. I access my ESXi host remotely with HP iLO via VPN. Am I correct in saying that I can copy the script from my remote system to the ESXi system WITHOUT enabling the unsupported mode and/or SSH if I use vCLI with command vifs?
2. Maybe I have missed something, but where do you actually store the ghettoVCB script? It seems that you can choose to store it on external or internal storage. I am interested in internal, but where is the appropriate location?
3. I understand that most users are starting the script from another system via SSH. This is well explained, but I am interested in scheduling the script from within the ESXi host. Now there are a few references to crontab (new to me) and some suggestions on how to set this up. Some say edit rc.local and others are doing something like this
*echo "0 2 * * 6 /vmfs/volumes/vmiscsi/tools/ghettoVCB4i.sh" > /var/spool/cron/crontabs/root*
1) Wrong, you'll need to enable the unsupported mode to both upload and configure/execute the script. You technically can use vifs to upload the script if you're going to be executing on a datastore that's not local to the ESXi hosts such as NFS,FC/iSCSI SAN but the configuration/setup will require the unsupported SSH console. The information regarding the upload, setup and configuration is defined in the documentation, it may not be explicitly state that you must do this and this but the assumption is made that users understand they'll need to unlock the unsupported console when using this script.
2) Again, this is a choice left up to the end users. As you can see there are advantages/disadvantages to storing the script on either internal or external storage. If you decide to store it locally and not have it rely on other sources, then you'll need to deal with the persistent configuration to ensure the script itself is persisted in a reboot and any type of cron jobs scheduled. There is no 'best practice' on where to store your script, that is for you to figure out and perhaps through trial/error you'll get a feel for what will work in your environment.
3) Again, there is no best practice. You're more than welcome to schedule this within ESXi, have an external VM whether that be Windows/Linux make an SSH connection and execute the backup job and run it in the background to ensure that no persisted TCP connection is required. As you know from reading through not only this thread but many others in the VMTN forum regarding configuring the cron jobs, there's more than one way and more than one location that'll keep the configurations persisted through a reboot.
One example can be found at this thread:
You can also find a nice detailed 3 part article by Raj on configuring this on a Windows system if you're more comfortable and familiar than on a UNIX/Linux system.
So, when you say provide a best practice, there really isn't one. The scope of this script is to provide a general backup solution that enables some flexibility on end users and if you need something more specific such as detail logging, compression, scheduling, etc. I expect end users to find/research the best solution that'll work in their operating environment.
Hopefully this clears up your question and again you can find more information by doing a search within the main VMTN forum as well. I'm sure you'll find many other threads that can help you understand some of what people have done, I know a very popular thread that contains implementation of this script can be found in ~last 10-15pages of:
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
Hello Lamw,
thanks for your work. All backups are running ok now.
The best free backup script ever written was the VISBU
The main important features were
1. Backup vm mentioned based on criteria powered on or off only
2. compress the backup
3. restore script included
Important features
1. Specify which vmdk's can be backed up in a vm for example we have a few vm's that have vmdk and an rdm so we specify the backup to only backup the vmdk and skip the rdm from the vm
2. CIFS/NFS/LOCAL DESTINATION
Unfortunately its no longer available, will this script have all the features and become the best free script to work on esx/esxi without any license needed from vmware ?
Please take a look at the documentation (this document) for the features provided with this script, if you can not find it, then it does not exists.
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
"Error: failed to extract VM_ID"
The solution is:
Check this fields on the VMX file:
displayName = "Vmname"
extendedConfigFile = "vmname.vmxf"
Both need be the same, example:
displayName = "vmname"
extendedConfigFile = "vmname.vmxf"
Hi,
i am using ghettoVCB4i.sh on ESXi 4.0.0 171294 and have some problemes with white spaces in VMs names.
While executing the Script i get the following errors:
ls: /vmfs/volumes/Storagesrv01_backups//itorga: No such file or directory
ls: backuptrigger: No such file or directory
ls: /vmfs/volumes/Storagesrv01_backups//dnie: No such file or directory
ls: workstation: No such file or directory
The names of the virtual machines are: "itorga backuptrigger" and "dnie workstation"
I checked the IFS:
IFS='
'
I think that the error occures in Line 314:
echo "Removing snapshot from $ ..."
while ls "$" | grep -q delta;
do
sleep 3
done
Does anybody has an idea how to fix this? I can't rename all VMs.
Thanks,
Stephan
For those of you who are trying to run the script via chronjob:
- Use a secound Linux machine
- Use ssh/authorized_keys file
- write/use a shell script like this:
The problem is the empty space, on the name of virtual machines. Remove it.
Hi tnol2,
as i said: i can't rename all the VMs
Hi!
Since there much more activity now here I want to ask you again if there is any idea about the problem posted several weeks ago.
We are using the 3.5 version of ghettoVCB.sh. If you need any more details - just let me know....
*-------
We are backing up 4 ESXi 3.5 servers successfully with about 6VMs each.
There is only one problem to backup a Debian Linux 60GB virtual harddisk. Snapshot seems to be OK. Backing up the disk (one of two) failed after some time with the following error message.
Taking backup snapshot for DEASX401 ... ################
Destination disk format: VMFS thick
Cloning disk '/vmfs/volumes/datastore1/DEASX401/DEASX401_2.vmdk'...
Clone: 79% done.Failed to clone disk : Insufficient permission to access file (38).
Destination disk format: VMFS thick
Cloning disk '/vmfs/volumes/datastore1/DEASX401/DEASX401.vmdk'...
Clone: 100% done.
Removing snapshot from DEASX401 ...
Completed backup for DEASX401! ####################
Start time: Wed Jul 1 06:45:27 UTC 2009
End time: Wed Jul 1 09:21:51 UTC 2009
Duration : 156.40 Minutes
Completed backing up specified Virtual Machines!
Might it be possible that the disk is to big? Is there any timeout?
Here some more information:
./ghettoVCB.sh is running with root account!
backup disk mouted vie NSF from a Win2003R2 server
share is an external 1GB USB disk
nsf shared folder is windows compressed (can save until 75% of original space)
*------
Regards,
Bjoern
Again, I'll tell you the same thing I told you awhile back, there are no known issues of timeout or VMDK being too large so long as you're under the < 2TB range.
The error dictates this to be a permission issue and not anything with the script. I would highly recommend you manually do a backup by hand to ensure that you are in fact able to backup using vmkfstools and isolate the problem that may be occuring.
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
Thank you. It seems I was not able to read your answer before.
I will try to do it manually using vmkfstools and give you feedback.
Hi,
I think you can greatly reduce the down time of a VM when you power it off before doing the backup by doing this:
1 - take down the VM
2 - create a snapshot
3 - restart the VM
4 - start the backup (without the snapshot files)
5 - remove the snapshot while the VM is on
The VM is down only the time to do the snapshot
what do you think of this ?
Majority of the use cases is live backup of a running VM, I don't know of many environments that can actually afford to take down their VMs/physical systems for backups. Again this option is present in the script if you wish to power down your VM, in which case a snapshot is NOT required as the VMDK is not locked. A snapshot is only necessary when it's running and a VMFS lock is issued and a snapshot will create a delta in which the main VMDK will be set to read-only allowing for the backup.
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
I do agree with you that usually, it's not possible to stop VM to do backups.
But you're script give the option to stop VM before backing up.
My post was just a little idea to try to minimize the down time of a VM IF you can stop it, and don't have to wait that the tons of gigs of the VMDK files be copied before restarting the VM.
How does GhettoVCB handle VMs that have virtual hard disks on two different volumes?
Thanks!
ghettoVCB handles it like a champ
If you take a look at this document, it provides a list of features, one of which is:
Fully support VMDK(s) stored across multiple datastores
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
Normally the vmdks are stored with the VMs. When the backup of a VM with a second vmdk on a different disk, does ghetto move the secondary vmdk files into the same directory as the other vmdk?