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,
I´am using your script successful on a server with an attached iSCSI storage.
On another server I tried to use the script for backup to an NFS storage. The NFS is built on an openSUSE 11. I can mount the NFS to the ESXi server but the script tells me, that the file system is read only.
What can be wrong with the NFS?
The NFS is built with four 256GB VMDKs wich are together a 1TB logical volume with ext3 (I also tried ext4). The logical volume is mounted to /mnt/nfs and the NFS storage shows to that mountpoint. This are the options for the NFS "fsid=0,crossmnt,ro,root_squash,sync,no_subtree_check".
Is there any error I do?
It's your NFS config which contains "ro" - meaning read-only. See William's section "Our NFS Server Configuration", under "NFS Export Options:".
-gaute
Hi gaute,
thanks for your reply. I have now set the option to "rw,async,all_squash,anonuid=99,anongid=99" but I get now the error permission denied. Is there any additional parameter I need?
Are you mounting the NFS volume as root and using the vSphere Client or esxcfg-nas?
=========================================================================
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 recently ran ghetto backup to backup a system with quiesce and memory switches turned on (backup memory). When I restored the system I expected it to come up where it had left off (during the backup glxgears were spinning) and I was logged on to the system via a console. After the backup we shutdown the original system and powered up the restored one. Shouldn't it have brought me into the console sessions with the glxgears running? If not, then what does the memory backup do? many thanks...
bando,
Sorry about the last reply, I must be having a brain freeze this morning (still recovering from a cold).
So this option was initially added for testing and in case users wanted the snapshot to also capture the state of the system in case something happened. This state is stored in the .vmsn file which corresponds to a VM snapshot being taken. The snapshot is used so that the primary disks would be unlocked and that we could back up the VM, once the backup completed, the snapshot would then be committed and the delta would be merged back and .vmsn would be removed. The backup would contain all changes up to the snapshot, all changes after would be in the "live" running VM and would not be captured as part of the backup. The backups will always contain an offline VM as it does not capture the snapshots/etc.
So the behavior is expected, unless you capture the specific snapshot + .vmsn, upon restore would you then keep the same state. Again, snapshots are not meant to be kept for long durations or backed up.
Another issue around the .vmsn is if you change hardware, you may not be able to power on the VM.
I thought I had this documented but perhaps I missed it, this maybe something I just need to remove all together in a future release to not cause any confusion.
Hopefully that answered your question.
=========================================================================
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".
Cool... this now sets me to thinking, and that leads to other questions:
1. The memory file size issue is mainly determining how many Gbytes of memory you have and that adds to the overall size of the backup & snapshot space... is that the concern?
2. While we're at it, I figure that for a minimum snapshot free space of an average 20Gbyte VM client that is backed up should be a couple Gbytes. Most clients I've backed up so far are on VM servers with plenty of Gbytes free space so no issues EXCEPT for one that failed because it had only 1/2 Gbytes free space. I test backed it up with the POWER_DOWN switch and it worked perfectly as expected. Is there a rule of thumb formula for determining snapshot space?
3. Our database backups are performed frequently and separate from the ghetto VM client backups. That way I perform a quiesced monthly backup of those mysql servers for the purpose of a "system" restore should we have a major failure. The ghetto client backup is a monthly thing mainly to restore the system, should we have a VM server or client failure; then the database would be restored separately. It seems like a prudent use of the tools... any comments?
Many thanks...
1) That is correct, when you capture the memory, now you have to account for the additional .vmsn which is equal to the size of the configured VM. Also, the script doesn't backup snapshots, so capturing the .vmsn would not be helpful. It's only useful when you revert/goto a specific snapshot (point in time) and you wanted to preserve memory state, remember all backups of the VM is offline whether or not the source was running or not.
2) No rule thumb or formula unfortunately, it really depends on the VM and the application that is running and how much changes are going on during the duration of the backup. The longer the backup takes to transfer, potentially larger the snapshot gets. I guess if you really want to be safe, the maximum size of a single snapshot that it could ever be generated (assuming no funny glitches) is the largest VM that you have in your environment. Remember a that a single snapshot can grow up to the original size of the VM and that multiple snapshots can surpass the size of your origianl VM. Though in general, I think 20-30% free space would be more than enough
3) Yea I've been asked about this and unfortunately I can't provide too much insight into it since it really depends on your database and number of transactions occuring. In general, it's a best practice to use tools such as VSS or other quiescing tools within the OS to ensure consistency, hence the quiesce option when taking a snapshot, I know on the db side there are things you could do, though I'm not a dba, so I can't confirm. It's good that you're at least capturing a system image in case of a failure, at least you'll have an image of the system. I know some users have played it safe and shutdown their database to take a backup, though I know majority of the environments out there can't take a downtime for backups and must do it live. I would also recommend looking at backups at the database layer, perhaps that might be better for things like SQL Server or Oracle
=========================================================================
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'd advise you drop the "all_squash,anonuid=99,anongid=99" config and try "no_root_squash". At least at first. If that works, you know the cause of your permissions problems.
I'd just use no_root_squash if I was you, but if you absolutely have to, you can then try to get it working with other permissions.
Thank you very much, the hint with "no_root_squash" was perfect. I have set my options now to "fsid=0,crossmnt,rw,no_root_squash,async,no_subtree_check,anonuid=99,anongid=99".
Can you re-run your backup using dryrun mode, unfortunately from these logs, there isn't much I can go off of.
Thanks
=========================================================================
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".
Dry run looks nice.... It founds the vmdk file.
So I don't recall if this is a use case I had tested extensively, where your "source" VM is not directly located at the root of the datastore, there is a sub-folder in which the VM is hosted in.
I would need to run a few tests to see if this would cause any 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".
Hi,
I've got an issue which is described here :
http://communities.vmware.com/message/1499246#1499246
More information :
- My datastore has 1.3T available.
- I use a local datastore for my backup (the VM are on the same datastore)
- I want to compress my backup
I'll erase the snapshot which prevent me to do the backup again, and I'll try to reproduce the issue in debug mode.
Careful with compression on ESXi, with ESXi 3.5 the maximum size is 4GB and with ESXi 4.0 the maximum size is 8GB. This is limitation of the ESXi unsupported Busybox console, so you won't be able to use compression to properly extract the contents upon a restore.
=========================================================================
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.... one thing i see... if i choose thin disk to backup everything goes OK.
What could be the problem using zeroedthick disk type?
>Careful with compression on ESXi, with ESXi 3.5 the maximum size is 4GB and with ESXi 4.0 the maximum size is 8GB.
Interesting... Does this limitation flow through to OVFTool as well? I had some enormous problems migrating a VM on ESXi 3.5 to another ESXi 3.5 box on the weekend due to what appeared to be a max size of 8GB per 'chunk'. But even creating an OVF with 7GB chunksize failed as well, so I'm not sure if this was related. Surprisingly migration using VM Converter worked flawlessly.
Anyway not trying to go too 'off-topic' with this - but am curious if the compression issues stated here would affect any app or script on these boxes and not just ghettoVCB?
That's pretty interesting, there shouldn't be any issues using any of the disk formats. Are you seeing this problem with all your VMs? or just this specific one? Can you verify this?
What disk format is your source VM and how big is it?
=========================================================================
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've not done any testing with ovftool, though I would hope not, though can't say for sure. The actual compressed limitation was identified by a user, I forget which comment it was noted in. This limitation of the utlities within the Busybox console, this should not affect classic ESX.
I've thought about it in the past to use ovftool to generate a backup but haven't spent much time and it might actually be pretty slow and on larger VMs, it might not be too effective.
Curious, have you ran into the same issue if you manually exported using the vSphere Client out to OVF format?
Regarding your general question, this probably affects any type of compression with the use of tar with any files within the unsupported console. Technically there shouldn't be anything that would need to compress a file larger than 8GB, even the backups that are taken of the ESXi configuration is in kb sizes. So there should not be a need, remember that this console is only for troubleshooting purposes, it's not meant to be a general console for you to install or store files. Hence 8GB probably is more than enough
I still need to update some documentation around the compressed limitation + XFS resolution to NFS problem that some of the users have seen. Hopefully get to that sometime this week and update the FAQ's.
Thanks
=========================================================================
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've thought about it in the past to use ovftool to generate a backup but haven't spent much time and it might actually be pretty slow and on larger VMs, it might not be too effective.
No, actually its pretty fast - mainly because the compression is very good. The problem, however, is that it forces you to power down the source VM before you start. That doesn't work for us in a 24/7 environment.
>Curious, have you ran into the same issue if you manually exported using the vSphere Client out to OVF format?
Strange thing is that using VM Converter (converting source VM to target VM across ESXi hosts) worked without an issue. Mind you, it took 6 hours to run on a 80GB drive. But it did maintain all the correct host configuration settings so I could restart the Linux VM afterwards without issue. This VM had grown over time and had multiple VMDKs on it, with LVM and the problem was doing a clone with ghettoVCB and trying to restore from that never let me maintain drive names, etc. making the LVM die on boot each time.
I haven't tried using any other tool to create the OVF file though. Since an OVF file would be (in essence) generic and could be restarted on any host, it certainly would be a desirable format for the backup to be saved in. I could see great benefits of backup to OVF and restore on a Xen Server, or VirtualBox, etc. if needed.
Myles
>Curious, have you ran into the same issue if you manually exported using the vSphere Client out to OVF format?
One other thing comes to mind here, though....
if the goal is to create a rapid backup AND rapid restore process, you could clone the VMDKs to other files, but possibly integrate OVFTool into the script to create the OVF and MF (Manifest) files for those VMDKs. I tried doing this with the VM not being in powered down state and it did work. Mind you, I could get the target system to boot, but I still ran into the LVM issue. That might be something separate but having both the VMDK files AND OVF files, etc. would mean you could restore on any other ESXi or OVF supported host quickly and have a full configuration and manifest of the original server if needed.
M
No, actually its pretty fast - mainly because the compression is very good. The problem, however, is that it forces you to power down the source VM before you start. That doesn't work for us in a 24/7 environment.
Cool, yea I don't use OVF much nor the export functionality, good to know. Yea one thing about that tool is that the source must be offline.
Strange thing is that using VM Converter (converting source VM to target VM across ESXi hosts) worked without an issue.
Converter actually creates a new VM on the destination and keeps the source running if it's coming from a live source, so you don't have any downtime, though it can take awhile as it transfer the data over.
ovftool might be something to investigate in, though now you'll include a new dependency that was not once there, since ovftool needs to run on a management system (Windows or Linux). The other problem, I believe ovftool uses the APIs and if it's regulated like all other vSphere API/SDK's, then it won't work on free licensed version of ESXi
If I get some free cycles from my other projects, I'll go ahead and do POC and see if it's something worth looking into deeper.
Thanks again for all the comments
=========================================================================
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".
>The other problem, I believe ovftool uses the APIs and if it's regulated like all other vSphere API/SDK's, then it won't work on free licensed version of ESXi
It did work just fine on 7 of the 8 VMs on my ESXi 3.5 box. Both in creating the OVF file and in restoring from OVF on the target box. Didn't look like anything stopped it from working even though it was working with ESXi
>ovftool might be something to investigate in, though now you'll include a new dependency that was not once there, since ovftool needs to run on a management system (Windows or Linux). The other problem, I believe ovftool uses the APIs and if it's regulated like all other vSphere API/SDK's, then it won't work on free licensed version of ESXi
When I tried to get OVFTool to work and failed, I did a bit of research on it (what it was, where it came from, etc.). What I found was that it looks like it came more from a consortium group rather than something proprietary with VMWare. I might be wrong on this, but as it is used across multiple virtualization technologies, I wouldn't be surprised if you find that it is actually complete free and open technology.
Myles
You mentioned ESXi 3.5, what version or Update? If you're on ESXi 3.5u2/u3, then you might be bypassing the license check due to VMware API bug which was fixed in U4+.
To really test this, you need to verify on ESXi 3.5u4+ or on ESXi 4.0. If you're able to export/import VMs using ovftool, then YES, this can be a solution for backups. Though I have a funny feeling that the APIs will block you, else this would be a hole they've not fixed and potentially can be exploited
=========================================================================
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 actually just did a quick test on latest version of ESXi 4.0u1 using ovftool on Windows and using free licensed version. I was able to successfully export/import a dummy VM w/o hitting any "restrictions". It looks ilke ovftool isn't checking for the licensing information. Also note that the whole vApp import/export is using something called NFC to actually perform the operations which is basically a simple http/https transfer which does actually bypass their licensing.
I'll think about how this might be incorporated into a backup solution, as you can see now, not only can the tool be platform independent (Windows or Linux), you might not even have to go into the Service Console for ESX or unsupported Busybox console for ESXi. All the work can be performed from a remote management host, and so long as it can talk to the storage in which you want to store the backup, it would work.
Thanks for this information, I'll have to ponder a bit for a solution
=========================================================================
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".
Situation: I have a Windows 2003 Server Std. that has two virtual hard drives on different physical hard drives. E.G. Separate data stores / vmdks. One, the C: drive, is the OS, and the other, the T: drive, Windows exports as an NFS volume which serves as a backup target. I noticed that I can use a config file now to alter the backup behavior of specific VMs, and in particular the ability to select which vmdks will be backed up.
Mission: Backup the Windows server C: drive, but not the T: drive NFS volume.
Problem: I set up the config file to backup only one of the two vmdks, the C: drive. Referencing the log below, when the script runs, it acknowledges the request to backup only one of the vmks, but it also shows in the execution area that it will backup both.
What am I missing? Thanks!
==============================================
A listing of /vmfs/volumes/datastore1/ghettoVCB looks like this:
admin2
admin2_list
admin2-backup.sh
ghettoVCB.sh
The script that calls it, admin2-backup.sh, contains this:
/vmfs/volumes/datastore1/ghettoVCB/ghettoVCB.sh -f /vmfs/volumes/datastore1/ghettoVCB/admin2_list -c /vmfs/volumes/datastore2/ghettoVCB -d dryrun -l /vmfs/volumes/nas-2/log/admin2-backup.log
The config, admin2 contains this:
VM_BACKUP_VOLUME=//vmfs/volumes/nas-1/backups/server2
DISK_BACKUP_FORMAT=thin
VM_BACKUP_ROTATION_COUNT=1
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
ADAPTER_FORMAT=lsilogic
VM_SNAPSHOT_MEMORY=0
VM_SNAPSHOT_QUIESCE=0
VMDK_FILES_TO_BACKUP="admin2.vmdk"
The log, /vmfs/volumes/nas-2/log/admin2-backup.log, contains this:
2010-03-24 21:01:19 -- info: ============================== ghettoVCB LOG START ==============================
2010-03-24 21:01:20 -- info: CONFIG - USING CONFIGURATION FILE = /vmfs/volumes/datastore1/ghettoVCB/admin2
2010-03-24 21:01:20 -- info: CONFIG - VM_BACKUP_VOLUME = //vmfs/volumes/nas-1/backups/server2
2010-03-24 21:01:20 -- info: CONFIG - VM_BACKUP_ROTATION_COUNT = 1
2010-03-24 21:01:20 -- info: CONFIG - DISK_BACKUP_FORMAT = thin
2010-03-24 21:01:20 -- info: CONFIG - ADAPTER_FORMAT = lsilogic
2010-03-24 21:01:20 -- info: CONFIG - POWER_VM_DOWN_BEFORE_BACKUP = 0
2010-03-24 21:01:20 -- info: CONFIG - ENABLE_HARD_POWER_OFF = 0
2010-03-24 21:01:20 -- info: CONFIG - ITER_TO_WAIT_SHUTDOWN = 4
2010-03-24 21:01:20 -- info: CONFIG - POWER_DOWN_TIMEOUT = 5
2010-03-24 21:01:20 -- info: CONFIG - SNAPSHOT_TIMEOUT = 15
2010-03-24 21:01:20 -- info: CONFIG - LOG_LEVEL = dryrun
2010-03-24 21:01:20 -- info: CONFIG - BACKUP_LOG_OUTPUT = /vmfs/volumes/nas-2/log/admin2-backup.log
2010-03-24 21:01:20 -- info: CONFIG - VM_SNAPSHOT_MEMORY = 0
2010-03-24 21:01:20 -- info: CONFIG - VM_SNAPSHOT_QUIESCE = 0
2010-03-24 21:01:20 -- info: CONFIG - VMDK_FILES_TO_BACKUP = admin2.vmdk
2010-03-24 21:01:20 -- dryrun: ###############################################
2010-03-24 21:01:20 -- dryrun: Virtual Machine: admin2
2010-03-24 21:01:20 -- dryrun: VM_ID: 304
2010-03-24 21:01:20 -- dryrun: VMX_PATH: /vmfs/volumes/datastore1/admin2/admin2.vmx
2010-03-24 21:01:20 -- dryrun: VMX_DIR: /vmfs/volumes/datastore1/admin2
2010-03-24 21:01:20 -- dryrun: VMX_CONF: admin2/admin2.vmx
2010-03-24 21:01:20 -- dryrun: VMFS_VOLUME: datastore1
2010-03-24 21:01:20 -- dryrun: VMDK(s):
2010-03-24 21:01:20 -- dryrun: /vmfs/volumes/4a3b4c4e-2d38530e-0c2c-003048d937e7/admin2/admin2_1.vmdk
2010-03-24 21:01:20 -- dryrun: admin2.vmdk
2010-03-24 21:01:20 -- dryrun: ###############################################
2010-03-24 21:01:20 -- info: ============================== ghettoVCB LOG END ================================
The output is expected based on your setup, you're running dryrun which does not go through the logic of validating a VM for backup or it's VMDK(s) etc. The verbiage may be miss-leading but this was put in place to help me in troubleshooting user issues.
When you go through the actual backup process, it'll go ahead and verify that all valid disks that are found will also be checked against VMDK_FILES_TO_BACKUP variable and check if it's set to either "all" in which case, all valid VMDK(s) will be backed up, else it'll compare the VMDK(s) to see which it should allow through.
=========================================================================
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".
Perfect! Thank you for answering, and so quickly. What an incredible script.
THANK YOU, THANK YOU, THANK YOU
np.
=========================================================================
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
this my problem: on my redhat it works but not on the other servers!
The size of these servers who are very big server can t he etre the reason?
/vmfs/volumes/4b7ecd5f-26a47d05-5b67-0026b975af67 # cat ghetto_VCB.log
2010-03-23 21:00:01 -- info: ============================== ghettoVCB LOG START ==============================
2010-03-23 21:00:01 -- info: CONFIG - VM_BACKUP_VOLUME = /vmfs/volumes/NFS/SAUVEGARDE/VM
2010-03-23 21:00:01 -- info: CONFIG - VM_BACKUP_ROTATION_COUNT = 3
2010-03-23 21:00:01 -- info: CONFIG - DISK_BACKUP_FORMAT = thin
2010-03-23 21:00:01 -- info: CONFIG - ADAPTER_FORMAT = buslogic
2010-03-23 21:00:01 -- info: CONFIG - POWER_VM_DOWN_BEFORE_BACKUP = 0
2010-03-23 21:00:01 -- info: CONFIG - ENABLE_HARD_POWER_OFF = 0
2010-03-23 21:00:01 -- info: CONFIG - ITER_TO_WAIT_SHUTDOWN = 3
2010-03-23 21:00:01 -- info: CONFIG - POWER_DOWN_TIMEOUT = 5
2010-03-23 21:00:01 -- info: CONFIG - SNAPSHOT_TIMEOUT = 15
2010-03-23 21:00:01 -- info: CONFIG - LOG_LEVEL = info
2010-03-23 21:00:01 -- info: CONFIG - BACKUP_LOG_OUTPUT = stdout
2010-03-23 21:00:01 -- info: CONFIG - VM_SNAPSHOT_MEMORY = 0
2010-03-23 21:00:01 -- info: CONFIG - VM_SNAPSHOT_QUIESCE = 0
2010-03-23 21:00:01 -- info: CONFIG - VMDK_FILES_TO_BACKUP = all
2010-03-23 21:00:03 -- info: Snapshot found for DNS-GLPI-OCS, backup will not take place
2010-03-23 21:00:03 -- info: Snapshot found for Toshiba-Efms, backup will not take place
2010-03-23 21:00:04 -- info: Initiate backup for RedHat
2010-03-23 21:00:04 -- info: Creating Snapshot "ghettoVCB-snapshot-2010-03-23" for RedHat
Destination disk format: VMFS thin-provisioned
Cloning disk '/vmfs/volumes/datastore2/RedHat/RedHat.vmdk'...
Clone: 100% done.
2010-03-23 21:07:47 -- info: Removing snapshot from RedHat ...
2010-03-23 21:07:52 -- info: Backup Duration: 7.80 Minutes
2010-03-23 21:07:52 -- info: Successfully completed backup for RedHat!
2010-03-23 21:07:54 -- info: Initiate backup for Samba Debian
2010-03-23 21:07:54 -- info: Creating Snapshot "ghettoVCB-snapshot-2010-03-23" for Samba Debian
2010-03-23 21:23:08 -- info: Snapshot timed out, failed to create snapshot: "ghettoVCB-snapshot-2010-03-23" for Samba Debian
2010-03-23 21:23:08 -- info: Backup Duration: 15.23 Minutes
2010-03-23 21:23:08 -- info: Error: Unable to backup Samba Debian due to snapshot creation!
2010-03-23 21:23:08 -- info: Snapshot found for zimbra, backup will not take place
2010-03-23 21:23:08 -- info: ============================== ghettoVCB LOG END ================================
2010-03-24 21:00:01 -- info: ============================== ghettoVCB LOG START ==============================
2010-03-24 21:00:01 -- info: CONFIG - VM_BACKUP_VOLUME = /vmfs/volumes/NFS/SAUVEGARDE/VM
2010-03-24 21:00:01 -- info: CONFIG - VM_BACKUP_ROTATION_COUNT = 3
2010-03-24 21:00:01 -- info: CONFIG - DISK_BACKUP_FORMAT = thin
2010-03-24 21:00:01 -- info: CONFIG - ADAPTER_FORMAT = buslogic
2010-03-24 21:00:01 -- info: CONFIG - POWER_VM_DOWN_BEFORE_BACKUP = 0
2010-03-24 21:00:01 -- info: CONFIG - ENABLE_HARD_POWER_OFF = 0
2010-03-24 21:00:01 -- info: CONFIG - ITER_TO_WAIT_SHUTDOWN = 3
2010-03-24 21:00:01 -- info: CONFIG - POWER_DOWN_TIMEOUT = 5
2010-03-24 21:00:01 -- info: CONFIG - SNAPSHOT_TIMEOUT = 60
2010-03-24 21:00:01 -- info: CONFIG - LOG_LEVEL = info
2010-03-24 21:00:01 -- info: CONFIG - BACKUP_LOG_OUTPUT = stdout
2010-03-24 21:00:01 -- info: CONFIG - VM_SNAPSHOT_MEMORY = 0
2010-03-24 21:00:01 -- info: CONFIG - VM_SNAPSHOT_QUIESCE = 0
2010-03-24 21:00:01 -- info: CONFIG - VMDK_FILES_TO_BACKUP = all
2010-03-24 21:00:02 -- info: Snapshot found for DNS-GLPI-OCS, backup will not take place
2010-03-24 21:00:02 -- info: Snapshot found for Toshiba-Efms, backup will not take place
2010-03-24 21:00:03 -- info: Initiate backup for RedHat
2010-03-24 21:00:03 -- info: Creating Snapshot "ghettoVCB-snapshot-2010-03-24" for RedHat
Destination disk format: VMFS thin-provisioned
Cloning disk '/vmfs/volumes/datastore2/RedHat/RedHat.vmdk'...
Clone: 100% done.
2010-03-24 21:07:44 -- info: Removing snapshot from RedHat ...
2010-03-24 21:07:49 -- info: Backup Duration: 7.77 Minutes
2010-03-24 21:07:49 -- info: Successfully completed backup for RedHat!
2010-03-24 21:07:50 -- info: Initiate backup for Samba Debian
2010-03-24 21:07:50 -- info: Creating Snapshot "ghettoVCB-snapshot-2010-03-24" for Samba Debian
2010-03-24 22:08:42 -- info: Snapshot timed out, failed to create snapshot: "ghettoVCB-snapshot-2010-03-24" for Samba Debian
2010-03-24 22:08:42 -- info: Backup Duration: 60.87 Minutes
2010-03-24 22:08:42 -- info: Error: Unable to backup Samba Debian due to snapshot creation!
2010-03-24 22:08:42 -- info: Snapshot found for zimbra, backup will not take place
2010-03-24 22:08:42 -- info: ============================== ghettoVCB LOG END ================================
Thank
francois
So you probably know why the backups aren't take place since the snapshots were not removed and backup script does not support VMs with existing snapshots.
Now the reason for this problem is not the script but from what I've seen being reported and primarily pertaining to an "NFS" configuration, potentially (hardware/software) that causes an issue with using NFS on ext3 vs NFS on XFS filesystem.
Please take a look at my comment here for some details: http://communities.vmware.com/docs/DOC-8760#comments-14679
Regarding why this occurs, I'm still not 100% sure. I've not been able to re-produce this and haven't found much commonality between the various reports, though it generally occurs from what I can tell on larger VMs but I believe there's been reports of this on smaller VMs as well.
Not enough users have gone through further troubleshooting to further isolate and there just hasn't been much feedback from the community after my comment from above.
Pretty confident that you're probably affected by this and if you implement the fix, the issue should go away.
I'm looking to update the documentation with some of these findings, if anyone would like to share more information about the issue, please let me know.
Thanks
=========================================================================
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 seem to be on here every few months with a new problem. I'm getting an error after the script backs up the first VM. Here is a screen capture:
/vmfs/volumes/48f62e13-c6958ca2-6bc2-0022198dec59 # ./ghettoVCB.sh -f vmbackups
(vim.fault.DuplicateName) {
dynamicType = ,
name = "NFS",
object = 'vim.Datastore:192.168.111.65:/mnt/vg1/data1/backup',
msg = "The name 'NFS' already exists."
}
2010-03-26 12:50:21 -- info: ============================== ghettoVCB LOG START ==============================
2010-03-26 12:50:21 -- info: CONFIG - VM_BACKUP_VOLUME =
2010-03-26 12:50:21 -- info: CONFIG - VM_BACKUP_ROTATION_COUNT = 5
2010-03-26 12:50:21 -- info: CONFIG - DISK_BACKUP_FORMAT = zeroedthick
2010-03-26 12:50:21 -- info: CONFIG - ADAPTER_FORMAT = lsilogic
2010-03-26 12:50:21 -- info: CONFIG - POWER_VM_DOWN_BEFORE_BACKUP = 0
2010-03-26 12:50:21 -- info: CONFIG - ENABLE_HARD_POWER_OFF = 0
2010-03-26 12:50:21 -- info: CONFIG - ITER_TO_WAIT_SHUTDOWN = 3
2010-03-26 12:50:21 -- info: CONFIG - POWER_DOWN_TIMEOUT = 5
2010-03-26 12:50:21 -- info: CONFIG - SNAPSHOT_TIMEOUT = 15
2010-03-26 12:50:21 -- info: CONFIG - LOG_LEVEL = info
2010-03-26 12:50:21 -- info: CONFIG - BACKUP_LOG_OUTPUT = stdout
2010-03-26 12:50:21 -- info: CONFIG - VM_SNAPSHOT_MEMORY = 0
2010-03-26 12:50:21 -- info: CONFIG - VM_SNAPSHOT_QUIESCE = 1
2010-03-26 12:50:21 -- info: CONFIG - VMDK_FILES_TO_BACKUP = all
2010-03-26 12:50:22 -- info: Initiate backup for LegalFiles
2010-03-26 12:50:22 -- info: Creating Snapshot "ghettoVCB-snapshot-2010-03-26" for LegalFiles
Destination disk format: VMFS thick
Cloning disk '/vmfs/volumes/BackupsStore/LegalFiles/LegalFiles_1.vmdk'...
Clone: 100% done.
Destination disk format: VMFS thick
Cloning disk '/vmfs/volumes/BackupsStore/LegalFiles/LegalFiles.vmdk'...
Clone: 100% done.
2010-03-26 13:58:07 -- info: Removing snapshot from LegalFiles ...
ash: 5.gz: bad number
./ghettoVCB.sh: ./ghettoVCB.sh: 735: Syntax error: 5.gz+1
Please take a look at my comment here: http://communities.vmware.com/docs/DOC-8760#comments-14997
I suspect you may be running into the lovely "nfs" issue that some of the other users are having. This has nothing to do with 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".
<b>"I suspect you may be running into the lovely "nfs" issue"</b>
I don't know about that. I set some debugging flags around the code as shown here.
checkVMBackupRotation() { set -x set -v ... set +x set +v }
I called the script with debug logging and redirected stdout and stderr to a file. The first backup made it, but the second one you can see ran into trouble.
Logging output to "/vmfs/volumes/nas-2/log/server2-backup.log" ... Destination disk format: VMFS thin-provisioned Cloning disk '/vmfs/volumes/datastore1/monitor/monitor.vmdk'... Clone: 0% done. Clone: 1% done. .... Clone: 99% done. Clone: 100% done. + set -v + local BACKUP_DIR_PATH=//vmfs/volumes/nas-1/backups/server2/monitor + local BACKUP_VM_NAMING_CONVENTION=//vmfs/volumes/nas-1/backups/server2/monitor/monitor-2010-03-26 + ls -tr //vmfs/volumes/nas-1/backups/server2/monitor + LIST_BACKUPS=monitor-2010-03-22--1 monitor-2010-03-26 + [ -z 1 ] + IFS= + TMP_DIR=//vmfs/volumes/nas-1/backups/server2/monitor/monitor-2010-03-22--1 + echo 1 + TMP=1 + [ 1 = //vmfs/volumes/nas-1/backups/server2/monitor/monitor-2010-03-26 ] + [ 1 -ge 1 ] + rm -rf //vmfs/volumes/nas-1/backups/server2/monitor/monitor-2010-03-22--1 + TMP_DIR=//vmfs/volumes/nas-1/backups/server2/monitor/monitor-2010-03-26 + echo //vmfs/volumes/nas-1/backups/server2/monitor/monitor-2010-03-26 + TMP=//vmfs/volumes/nas-1/backups/server2/monitor/monitor-2010-03-26 + [ //vmfs/volumes/nas-1/backups/server2/monitor/monitor-2010-03-26 = //vmfs/volumes/nas-1/backups/server2/monitor/monitor-2010-03-26 ] + NEW=//vmfs/volumes/nas-1/backups/server2/monitor/monitor-2010-03-26--1 + mv //vmfs/volumes/nas-1/backups/server2/monitor/monitor-2010-03-26 //vmfs/volumes/nas-1/backups/server2/monitor/monitor-2010-03-26--1 + unset IFS + set +x Destination disk format: VMFS thin-provisioned Cloning disk '/vmfs/volumes/datastore1/findlocw/findlocw.vmdk'... Clone: 0% done. Clone: 1% done. .... Clone: 99% done. Clone: 100% done. + set -v + local BACKUP_DIR_PATH=//vmfs/volumes/nas-1/backups/server2/findlocw + local BACKUP_VM_NAMING_CONVENTION=//vmfs/volumes/nas-1/backups/server2/findlocw/findlocw-2010-03-26 + ls -tr //vmfs/volumes/nas-1/backups/server2/findlocw + LIST_BACKUPS=findlocw-2010-03-23 findlocw-2010-03-24 findlocw-2010-03-25 findlocw-2010-03-26 + [ -z 1 ] + IFS= + TMP_DIR=//vmfs/volumes/nas-1/backups/server2/findlocw/findlocw-2010-03-23 + echo //vmfs/volumes/nas-1/backups/server2/findlocw/findlocw-2010-03-23 + TMP=//vmfs/volumes/nas-1/backups/server2/findlocw/findlocw-2010-03-23 + [ //vmfs/volumes/nas-1/backups/server2/findlocw/findlocw-2010-03-23 = //vmfs/volumes/nas-1/backups/server2/findlocw/findlocw-2010-03-26 ] + [ //vmfs/volumes/nas-1/backups/server2/findlocw/findlocw-2010-03-23 -ge 1 ] sh: //vmfs/volumes/nas-1/backups/server2/findlocw/findlocw-2010-03-23: bad number + echo //vmfs/volumes/nas-1/backups/server2/findlocw/findlocw-2010-03-23 + BASE=//vmfs/volumes/nas-1/backups/server2/findlocw/findlocw-2010-03-23 /vmfs/volumes/datastore1/ghettoVCB/ghettoVCB.sh: line 739: syntax error: //vmfs/volumes/nas-1/backups/server2/findlocw/findlocw-2010-03-23+1
Line 739 is the call to ghettoVCB().
The following is the log file for the same run:
2010-03-26 21:32:08 -- info: ============================== ghettoVCB LOG START ============================== 2010-03-26 21:32:09 -- info: CONFIG - VM_BACKUP_VOLUME = //vmfs/volumes/nas-1/backups/server2 2010-03-26 21:32:09 -- info: CONFIG - VM_BACKUP_ROTATION_COUNT = 1 2010-03-26 21:32:09 -- info: CONFIG - DISK_BACKUP_FORMAT = thin 2010-03-26 21:32:09 -- info: CONFIG - ADAPTER_FORMAT = lsilogic 2010-03-26 21:32:09 -- info: CONFIG - POWER_VM_DOWN_BEFORE_BACKUP = 0 2010-03-26 21:32:09 -- info: CONFIG - ENABLE_HARD_POWER_OFF = 0 2010-03-26 21:32:09 -- info: CONFIG - ITER_TO_WAIT_SHUTDOWN = 3 2010-03-26 21:32:09 -- info: CONFIG - POWER_DOWN_TIMEOUT = 5 2010-03-26 21:32:09 -- info: CONFIG - SNAPSHOT_TIMEOUT = 15 2010-03-26 21:32:09 -- info: CONFIG - LOG_LEVEL = info 2010-03-26 21:32:09 -- info: CONFIG - BACKUP_LOG_OUTPUT = /vmfs/volumes/nas-2/log/server2-backup.log 2010-03-26 21:32:09 -- info: CONFIG - VM_SNAPSHOT_MEMORY = 0 2010-03-26 21:32:09 -- info: CONFIG - VM_SNAPSHOT_QUIESCE = 0 2010-03-26 21:32:09 -- info: CONFIG - VMDK_FILES_TO_BACKUP = all 2010-03-26 21:32:10 -- info: Initiate backup for monitor 2010-03-26 21:32:10 -- info: Creating Snapshot "ghettoVCB-snapshot-2010-03-26" for monitor Destination disk format: VMFS thin-provisioned Cloning disk '/vmfs/volumes/datastore1/monitor/monitor.vmdk'... Clone: 0% done. Clone: 1% done. .... Clone: 99% done. Clone: 100% done. 2010-03-26 21:56:59 -- info: Removing snapshot from monitor ... 2010-03-26 21:57:05 -- info: Backup Duration: 24.92 Minutes 2010-03-26 21:57:05 -- info: Successfully completed backup for monitor! 2010-03-26 21:57:05 -- info: CONFIG - VM_BACKUP_VOLUME = //vmfs/volumes/nas-1/backups/server2 2010-03-26 21:57:05 -- info: CONFIG - VM_BACKUP_ROTATION_COUNT = 1 2010-03-26 21:57:05 -- info: CONFIG - DISK_BACKUP_FORMAT = thin 2010-03-26 21:57:05 -- info: CONFIG - ADAPTER_FORMAT = lsilogic 2010-03-26 21:57:05 -- info: CONFIG - POWER_VM_DOWN_BEFORE_BACKUP = 0 2010-03-26 21:57:05 -- info: CONFIG - ENABLE_HARD_POWER_OFF = 0 2010-03-26 21:57:05 -- info: CONFIG - ITER_TO_WAIT_SHUTDOWN = 3 2010-03-26 21:57:05 -- info: CONFIG - POWER_DOWN_TIMEOUT = 5 2010-03-26 21:57:05 -- info: CONFIG - SNAPSHOT_TIMEOUT = 15 2010-03-26 21:57:05 -- info: CONFIG - LOG_LEVEL = info 2010-03-26 21:57:05 -- info: CONFIG - BACKUP_LOG_OUTPUT = /vmfs/volumes/nas-2/log/server2-backup.log 2010-03-26 21:57:05 -- info: CONFIG - VM_SNAPSHOT_MEMORY = 0 2010-03-26 21:57:05 -- info: CONFIG - VM_SNAPSHOT_QUIESCE = 0 2010-03-26 21:57:05 -- info: CONFIG - VMDK_FILES_TO_BACKUP = all 2010-03-26 21:57:06 -- info: Initiate backup for findlocw Destination disk format: VMFS thin-provisioned Cloning disk '/vmfs/volumes/datastore1/findlocw/findlocw.vmdk'... Clone: 0% done. Clone: 1% done. .... Clone: 99% done. Clone: 100% done.
Let me try to explain what's going on so you understand the problem, as I've said before, the issue is not with the script.
+ [ //vmfs/volumes/nas-1/backups/server2/findlocw/findlocw-2010-03-23 -ge 1 ] sh: //vmfs/volumes/nas-1/backups/server2/findlocw/findlocw-2010-03-23: bad number
The reason this is failing is because when it extracts the sub-numbers in which the individual backups are being re-named for rotation, it's unable to find a value and hence the comparison fails. The reason this is occurring is the source folder that the actual backup is in, never got renamed as it was supposed to be and it fails the check condition. The whole "NFS" issue has shown itself in various ways forms, but majority of the problems have been around the rotation and deletion of the backups. For some reason, as already explained in few previous post, the I/O operation that's sent is either taking too long or never completes within a timely manner which causes all sorts of "funny" things either no rotating of the directories or left behind snapshots that were not able to be committed.
Again, these issues have always been reported around "NFS" and large VMs. I suspect that smaller VMs don't have this problem but once you get into larger VMs, this "I/O" issue with either the host or NFS server will start to show up. One resolution that a user has found was by changing their NFS server volume from ext3 to XFS which helped in resolving the problem and could be due to the overhead that ext3 brings in the way it does its update when an I/O request is sent compared to XFS.
So my question to you is, what is difference between VM1 and VM2 in terms of size? If you want to test this theory out it's pretty simple, take the NFS server out of the picture. If you have sufficient space on local volume, do a backup and see if you run into the issue? I know others have ran these tests and found that backups always complete. I know plenty of users that are able to backup across all 3 types of datastores perfectly fine, including NFS and it's only a small set of users that are seeing this problem.
Hopefully this makes a little more sense, so that's why I suggested that you're most liekly seeing the "NFS" issue as others are.
=========================================================================
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".
<b>So my question to you is, what is difference between VM1 and VM2 in terms of size?</b>
When I did this test, I switched them around to make the smaller one go first so I didn't have to wait so long for the results. The first one did make it, and the second, larger one, did not. But I had done that before to get a backup of the smaller one, and it failed.
<b>The reason this is failing is because when it extracts the sub-numbers in which the individual backups are being re-named for rotation, it's unable to find a value and hence the comparison fails...Hopefully this makes a little more sense</b>
I read the previous posts and links earlier but that sentence clarifies your position on what is going on better than all of the posts put together. I gather from what you are saying that the command completes, and when the next one executes, either the rename hasn't completed, or the call to the directory returns old information. I would guess the latter.
<b>...that's why I suggested that you're most likely seeing the "NFS" issue as others are. </b>
Your explanation is logical, and I don't understand the code right there well enough to be sure. However, there are a couple of details that don't fit the profile.
1. I'm not using EXT3 or XFS, I'm using NTFS on BOTH servers that cross-backup VMs to each other at night.
2. This has been working fine for a long time with large VMs on the same two NFS volumes. Now they both fail.
Possible Solution:
In order to make my situation fit the NFS theory, I initially reasoned that the problem may have crept in as the result of a Microsoft update. That would make both servers having the same problem at the same time, fit. However, I kept coming back to why the small VM backs up without error now, while it didn't before. While reflecting on that, I noticed that I had renamed parent directory to preserve my known-good backups while experimenting. I had done that with none of the others. I then did that with the others. Last night, all of the backups executed flawlessly, including proper rotation of the small VM that had started working earlier.Possible cause:
Earlier, I mentioned one of the things that I liked about your new script is the ability to specify which VMDKs get backed up. In the case of the two Windows 2003 R2 Servers that export the NFS volumes for the backups, it is important that I don't replicate their NFS volumes, not only due to their size, but because it would senseless to get a backups of a backups, and then store them back on the same server as the VMs they were backing up. I used to have a separate hacked script to backup the main VMDKs for each of those servers. However, I also had to schedule the WIndows machines separately, and make sure there was enough time between them so they would not overlap. If they were to overlap, their snapshots would snowball as they record changes of the changes of the changes.... After they complete, the nightly free-for-all backup begins where they cross-backup VMs to each other without issue. One time they did overlap, and while they were snowballing, the nightly backups kicked. I came back to packed NFS drives on both servers. I rebooted, but then none of the VMs would start. However, I always build in an "air-bubble" for things like this so I logged into the ESXi servers and deleted them to make space. I booted the servers, started the VIMs, and cleaned house. That's the only thing that I can THINK of that could have triggered this.Until last night, I've been adjusting the list orders to get backups and deleting the old ones by hand. This is the first time in 6 weeks this has worked right. One good day in a row does not equal a track record. I'll update this in a few days with the results.
PS: Thanks again for the awesome script!
Thanks for the updates, as you can see I get a few questions around these issues per week and in general the NFS issues have been the culprit from what I can tell. In your situation, it sounds like directories that were expected were modified which potentially broke the rotation. I'll need to think about this and see if there's a way I can help protect or better log this event. The other thing you mentioned about "overlap", one thing I could do is setup a lock which would be generated upon the start of the script and hopefully removed at the end of the script. If any "unexpected" errors were to happen and the lock would not be removed, then some logic would need to be written to ensure the script isn't running and remove the lock and re-lock.
Let me know if you have any ideas around this and thanks for the patience. I've been quite fortunate to have such a great and huge community ( script has gotten over 200,000+ views) to help QA this script. That's why I've been pretty confident to state that it's probably not the script and the issue lies in either "manual" manipulation of some sort OR environmental issues. If there was a real bug within the script, we would have more users reporting problems. There are definitely some things I'm thinking about adding into a future release and there have been suggestions around some of those features. Let me ponder about it some more and perhaps I'll provide an update of the "suggested" features and I'll go ahead and take any additional and see if it makes sense.
What I will do this weekend is update some of the documentation and FAQ's around some of the things I've learned over the last few weeks that users may have ran into.
Thanks
=========================================================================
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".
<b>Let me know if you have any ideas around this</b>
This is how I'm handling the situation now:
Other:
For now, I left the set -vx, set -xv pair around the code in question in ghettoVCB. I maintain two calls in the admin?-backup.sh scripts that call ghettoVCB, one normal, and one debug. The debug option gives me a second log file that contains the commands in the order they executed and the contents of the variables for the tagged area, and any exit errors...... # Normal #/vmfs/volumes/datastore1/ghettoVCB/ghettoVCB.sh -f /vmfs/volumes/datastore1/ghettoVCB/server2_list -c /vmfs/volumes/datastore1/ghettoVCB -l /vmfs/volumes/nas-2/log/server2-backup.log # Debug /vmfs/volumes/datastore1/ghettoVCB/ghettoVCB.sh -f /vmfs/volumes/datastore1/ghettoVCB/server2_list -c /vmfs/volumes/datastore1/ghettoVCB -d debug -l /vmfs/volumes/nas-2/log/server2-backup.log >/vmfs/volumes/nas-2/log/server2-debug.log 2>&1 .....
Thank you for your very valuable time with this.
My comment around ideas, was for features to be added to the script and not specific to your backup process.
e.g. Add a locking mechanisms to the script to ensure that only 1 instance can run at any given time.
=========================================================================
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 everyone,
I've just updated the documentation, for those that are affected by the "NFS" issue, please take a look at FAQ #29 for some details.
I will also be accepting any new feature requests and take a look at what are the most popular ones and how they might be integrated into a future release of the script. Keep in mind, feature adds will be based on feasibility and amount of free time I have.
Thanks for everyone support!
=========================================================================
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".
<b>My comment around ideas, was for features to be added to the script and not specific to your backup process.</b>
Your script serializes the backups in the list. What I wrote demonstrates how to serialize backups among servers by placing them in the same calling script. This ensures only one instance of ghettoVCB is running at a given time. Moreover, by further adding scripts that call the concurrent backups to the same script, I can force them to wait until the serialized backups are complete before starting them on separate threads to run concurrently. Each off those threads are able to serialize their own operations where necessary, in this case, mailing their logs. This method eliminates the complexities associated with semaphores.
<b>Add a locking mechanisms to the script to ensure that only 1 instance can run at any given time.</b>
Disclaimer: I'm a language and OS programmer, not a script programmer. To enforce that no more than one instance of ghettoVCB.sh can run on a VM at any given time, what comes to mind is to employ a method similar to what the operating system uses with pid files. The best place to store the "pid" files is someplace you can write, and someplace that gets cleared when VMWare reboots. The "pid" file is simply has a known file name that you'll be overwriting periodically in order to maintain its timestamp. What follows depends on the script processor having the ability to register a timer and process events. It would work something like this:
When ghettoVCB launches, and checks for its assigned "pid" file name. If when it starts up and it finds its "pid" and it's up to date, it exits because that means a copy of the ghettoVCB is active. If it doesn't find it, or it's out of date, it would write a new "pid" file, and continue to start, and register a timer to generate a timer event say every 5 seconds. When the event fires, it runs code that overwrites the "pid" file to update the timestamp, and then goes back to what it was doing. When ghettoVCB exits, it removes its "pid" file.
PS: This was longer, and I explained how to make your own timer if the script cannot register a timer, but it got blown away when I posted it.
Hi
The problem is resolved, my blocksize of my datastore was 1,
The snapshot could not be made because not enough available disk space, I modified my blocksize in 8 and the saving was made.
Thanck
francois
francois
Hi
I use the script to backup one server on an ESXi4.0 free Edition host.
A test backup of an other vm finalized successfully but if I want to backup the one vm that is important (a buildserver) there were several errors:
- First I want the vm to be backed up during execution. In time of backup there are no users logged in and no buildtask was running. There were no snapshots. The script startet to take a snapshot, tried to clone disks, failed and then and that is really annoying don't revert the snapshots. The next run couldnt work fine.
- Ok than I prepared the script to shutdown the vm so there will be no snapshotting.
- Now the problem is, that the script apparently couldn't find the vmdks????
Here are the log entries:
2010-03-26 07:10:02 -- info: ============================== ghettoVCB LOG START
2010-03-26 07:10:02 -- info: CONFIG - VM_BACKUP_VOLUME = /vmfs/volumes/4ae0b8d4-74b64288-137e-001cc0f2d1dd/Backup
2010-03-26 07:10:02 -- info: CONFIG - VM_BACKUP_ROTATION_COUNT = 2
2010-03-26 07:10:02 -- info: CONFIG - DISK_BACKUP_FORMAT = zeroedthick
2010-03-26 07:10:02 -- info: CONFIG - ADAPTER_FORMAT = buslogic
2010-03-26 07:10:02 -- info: CONFIG - POWER_VM_DOWN_BEFORE_BACKUP = 1
2010-03-26 07:10:02 -- info: CONFIG - ENABLE_HARD_POWER_OFF = 1
2010-03-26 07:10:02 -- info: CONFIG - ITER_TO_WAIT_SHUTDOWN = 3
2010-03-26 07:10:02 -- info: CONFIG - POWER_DOWN_TIMEOUT = 6
2010-03-26 07:10:02 -- info: CONFIG - SNAPSHOT_TIMEOUT = 15
2010-03-26 07:10:02 -- info: CONFIG - LOG_LEVEL = info
2010-03-26 07:10:02 -- info: CONFIG - BACKUP_LOG_OUTPUT = stdout
2010-03-26 07:10:02 -- info: CONFIG - VM_SNAPSHOT_MEMORY = 1
2010-03-26 07:10:02 -- info: CONFIG - VM_SNAPSHOT_QUIESCE = 0
2010-03-26 07:10:02 -- info: CONFIG - VMDK_FILES_TO_BACKUP = all
2010-03-26 07:10:12 -- info: Powering off initiated for Buildserver, backup will not begin until VM is off...
2010-03-26 07:10:18 -- info: VM is still on - Iteration: 0 - sleeping for 60secs (Duration: 0 seconds)
2010-03-26 07:11:25 -- info: VM is powerdOff
2010-03-26 07:11:25 -- info: Initiate backup for Buildserver
Failed to clone disk : The file already exists (39).
Destination disk format: VMFS zeroedthick
Cloning disk '/vmfs/volumes/datastore2/Windows XP Pro SP3 Ger 05/
Clone: 1% done.
...
Clone: 100% done.
Failed to clone disk : The system cannot find the file specified (25).
Destination disk format: VMFS zeroedthick
Cloning disk '/vmfs/volumes/datastore2/Windows XP Pro SP3 Ger 05/Windows XP Pro SP3 Ger 05.vmdk'...
2010-03-26 07:14:05 -- info: Powering back on Buildserver
2010-03-26 07:14:05 -- info: Compressing VM backup "/vmfs/volumes/4ae0b8d4-74b64288-137e-001cc0f2d1dd/Backup/Buildserver/Buildserver-2010-03-26.gz"...
2010-03-26 07:14:06 -- info: Backup Duration: 2.78 Minutes
2010-03-26 07:14:06 -- info: Successfully completed backup for Buildserver!
2010-03-26 07:14:06 -- info: ============================== ghettoVCB LOG END
What should that mean?
I would appreciate for an answer!
Regards
Matthias
Yes, not having the right blocksize can affect the backups I'm going to assume users have a properly configured environment when using 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".
Please read FAQ0
=========================================================================
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
ok what is the right blocksize?
It is set to 1 MB and the greatest file could be 265 GB
Regards
Hi
By defaut with one " block size " of 1M what allows maximal partitions only of 256G.
To exploit the integralité of the disk it is necessary to pass has a block size of 2M for a maximal partition of 512Go, of 4M for a maximal partition of 1To and of 8M for a maximal partition of 2To.
francois
ok what is the right blocksize?
The answer is, it depends. With vSphere, there's probably not a whole lot of reason not to use 8MB by default, especially with the sub-block allocation.
Give these two links a read for further details:
http://www.yellow-bricks.com/2009/05/14/block-sizes-and-growing-your-vmfs/
http://www.yellow-bricks.com/2009/03/24/an-8mb-vmfs-blocksize-doesnt-increase-performance/
Another issue that we've personally ran into, which others could also is when you have a VM that has it's VMDK(s) spread across multiple datastores. The datastoer in which the VM's .vmx is located in has a smaller blocksize than the other datastore hosting the VM's disk will cause an issue and when you try to snapshot the VM, it'll fail.
Take a look at this article for further details:
http://www.yellow-bricks.com/2009/08/24/vsphere-vm-snapshots-and-block-size/
Regarding your problem, this may or may not be the problem. Though this is not a beginner's script, so I expect user's to have a properly configured environment before using the script.
Please go through the documentation + FAQ and see if you're falling into any of those "known" issues. If you still can't find a resolution, please take a look at FAQ1 before re-posting.
Thanks
=========================================================================
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".