Setting up a ESXi 4.1 (free version) backup system
Requirement software on hand:
- ghettoVCB-20100727.tar.gz. or the lastest version
- Veeam_fastscp_3.0.3.272_u.zip (free with schedule tasks) or the lastest free version (not sure about the new version did not test)
- Putty
Install Veeam to backup server (Windows XP/7 Joined to domain).
In Veeam, copy ghettoVCB to ESXi server in datastore1 folder.
Use PUTTY to remote to ESXi server
Extract the contents of the tarball:
[root@himalaya ~]# tar -zxvf ghettoVCB.tar.gz
The script is now ready to be used and is located in a directory named ghettoVCB
[root@himalaya ghettoVCB]# ls -l
total 36
-rwxr-xr-x 1 root root 28775 Mar 27 11:31 ghettoVCB.sh
-rw-r--r-- 1 root root 380 Mar 27 11:31 ghettoVCB-vm_backup_configuration_template
Setup QNAP to use NFS share or some kind of NSF server
I setup a folder with NFS share
Now back to ESXi in PUTTY
Edit the ghettoVCB.sh file
Example of my config file: (in Red color is my changes)
########################################################################
VM_BACKUP_VOLUME=/vmfs/volumes/ESXDatastore1
# Format output of VMDK backup
# zeroedthick
# 2gbsparse
# thin
# eagerzeroedthick
DISK_BACKUP_FORMAT=zeroedthick
# Number of backups for a given VM before deleting
VM_BACKUP_ROTATION_COUNT=1
# Shutdown guestOS prior to running backups and power them back on afterwards
# This feature assumes VMware Tools are installed, else they will not power down and loop forever
# 1=on, 0 =off
POWER_VM_DOWN_BEFORE_BACKUP=0
# enable shutdown code 1=on, 0 = off
ENABLE_HARD_POWER_OFF=0
# if the above flag "ENABLE_HARD_POWER_OFF "is set to 1, then will look at this flag which is the # of iterations
# the script will wait before executing a hard power off, this will be a multiple of 60seconds
# (e.g) = 3, which means this will wait up to 180seconds (3min) before it just powers off the VM
ITER_TO_WAIT_SHUTDOWN=3
# Number of iterations the script will wait before giving up on powering down the VM and ignoring it for backup
# this will be a multiple of 60 (e.g) = 5, which means this will wait up to 300secs (5min) before it gives up
POWER_DOWN_TIMEOUT=5
# enable compression with gzip+tar 1=on, 0=off
ENABLE_COMPRESSION=0
############################
####### NEW PARAMS #########
############################
# Disk adapter type: buslogic, lsilogic or ide
ADAPTER_FORMAT=buslogic
# Include VMs memory when taking snapshot
VM_SNAPSHOT_MEMORY=0
# Quiesce VM when taking snapshot (requires VMware Tools to be installed)
VM_SNAPSHOT_QUIESCE=0
##########################################################
# NON-PERSISTENT NFS-BACKUP ONLY
#
# ENABLE NON PERSISTENT NFS BACKUP 1=on, 0=off
ENABLE_NON_PERSISTENT_NFS=0
# umount NFS datastore after backup is complete 1=yes, 0=no
UNMOUNT_NFS=0
# IP Address of NFS Server
NFS_SERVER=192.168.5.39
# Path of exported folder residing on NFS Server (e.g. /some/mount/point )
NFS_MOUNT=/ESXDatastore1
# Non-persistent NFS datastore display name of choice
NFS_LOCAL_NAME=ESXDatastore1
# Name of backup directory for VMs residing on the NFS volume
NFS_VM_BACKUP_DIR=ESXDatastore1
Example on how to run ghettoVCB: (I use only ./ghettoVCB.sh –a)
Usage:
[root@himalaya ghettoVCB]# ./ghettoVCB.sh
###############################################################################
#
# ghettoVCB for ESX/ESXi 3.5 & 4.x+
# Author: William Lam
# http://www.virtuallyghetto.com/
# Created: 11/17/2008
# Last modified: 07/27/2010
#
###############################################################################
Usage: ghettoVCB/ghettoVCB.sh -f [VM_BACKUP_UP_LIST] -c [VM_CONFIG_DIR] -l [LOG_FILE] -d [DEBUG_LEVEL] -g [GLOBAL_CONF] -e [VM_EXCLUSION_LIST]
OPTIONS:
-a Backup all VMs on host
-f List of VMs to backup
-c VM configuration directory for VM backups
-g Path to global ghettoVCB configuration file
-l File to output logging
-d Debug level [info|debug|dryrun] (default: info)
(e.g.)
Backup VMs stored in a list
ghettoVCB/ghettoVCB.sh -f vms_to_backup
Backup all VMs residing on this host
ghettoVCB/ghettoVCB.sh -a
Backup all VMs residing on this host except for the VMs in the exclusion list
ghettoVCB/ghettoVCB.sh -a -e vm_exclusion_list
Backup VMs based on specific configuration located in directory
ghettoVCB/ghettoVCB.sh -f vms_to_backup -c vm_backup_configs
Backup VMs using global ghettoVCB configuration file
ghettoVCB/ghettoVCB.sh -f vms_to_backup -g /global/ghettoVCB.conf
Output will log to /tmp/ghettoVCB.log
ghettoVCB/ghettoVCB.sh -f vms_to_backup -l /tmp/ghettoVCB.log
Dry run (no backup will take place)
ghettoVCB/ghettoVCB.sh -f vms_to_backup -d dryrun
To do a schedule in crontab:
Cronjob FAQ:
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.
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 ESXi:
1. Setup the cronjob by appending the following line to /var/spool/cron/crontabs/root:
Since root is read-only file to need to change it to writeable. I backup a copy of root first.
Type in chmod +w root
Now you can add the line below
0 0 * * 1-5 /vmfs/volumes/datastore1/ghettoVCB/ghettoVCB.sh -a > /vmfs/volumes/datastore1/ghettoVCB-backup-$(date +\%s).log
Change the root back to read-only by chmod -w root
/var/spool/cron/crontabs # ls -l
-r--r--r-- 1 root root 285 Nov 3 15:55 root
-r--r--r-- 1 root root 158 Nov 1 18:25 rootbk
Kill the current crond (cron daemon) and then restart the crond for the changes to take affect:
On ESXi 4.0
~ # kill $(cat /var/run/crond.pid)
~ # busybox crond
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)
On ESXi 4.0
/bin/kill $(cat /var/run/crond.pid)
/bin/echo "0 0 * * 1-5 /vmfs/volumes/datastore1/ghettoVCB/ghettoVCB.sh -a > /vmfs/volumes/datastore1/ghettoVCB-backup-\$(date +\\%s).log" >> /var/spool/cron/crontabs/root
/bin/busybox crond
On Windows 2003 backup server, run Veeam
Create a backup job for the virtual machines
I put them in my external USB drive.
Back to backup server (XP/7)
Once you have the ghettovbc backup to NFS share with success, you can use Veeam to point to the NFS share folder to backup to an external hard drive.
Done