Text Size

Like many others that work with the free version of ESXi, I think VMware should have included an easy way to backup virtual machines even if it was just a copy to another Datastore. Knowing that backups are extremely important, I have looked all over trying to find a simple and free way to backup the free version of ESXi Server.

This is a backup that is going to an NFS Datastore but it could easily be any other Datastore setup in ESXi

Backups can take a lot of time so to avoid any downtime it is best to schedule them to run at night. See my article on Scheduling your ESXi Backup.

Requirements:

  • This backup solution requires an available NFS server or an alternate ESXi Datastore.
  • Enough hard drive space on the NFS Share or alternate Datastore.
  • ghettoVCB.zip - I found the backup script on the VMware Communities site. You must modify it to work in your environment. The latest version of the script can be found here, http://communities.vmware.com/docs/DOC-8760. For more cool scripts like this please checkout virtuallyghetto.com.
  • SSH Access to the ESXi console enabled.

If you are using Windows and want to enable NFS follow the article Connect ESXi to Windows Based NFS. This will also take you through enableing SSH access.

To enable SSH read the article Enable SSH in ESXi.

Now that you have your Datastore and SSH enabled, it's time to configure the backup script.

This script requires very little configuration but it does require a file that lists the VMs that you wish to backup. The script only requires that path to the datastore be edited to work corretly. 

# directory that all VM backups should go (e.g. /vmfs/volumes/SAN_LUN1/mybackupdir) VM_BACKUP_VOLUME=/vmfs/volumes/EnterNFS-StorageNameHere

Change "EnterNFS-StorageNameHere" to the name of the NFS datastore where you want the backups to go save the script and you are ready to move the file to the server.

If you would like to modify the number of backups that are saved change the VM BACKUP ROTATION COUNT varialbe to the number of backups that you would like to keep. The default is 3

# Number of backups for a given VM before deleting
VM_BACKUP_ROTATION_COUNT=5

A newer feature to the script is the ability for the script to send an email log of the backup status. Make sure to modify the parameters so you will get an email of the backup status once it's completed.

############################
######### EMAIL ############
############################

# Email debug 1=yes, 0=no
EMAIL_DEBUG=0

# Email log 1=yes, 0=no
EMAIL_LOG=1

# Email SMTP server
EMAIL_SERVER=192.168.1.200

# Email SMTP server port
EMAIL_SERVER_PORT=25

# Email FROM
EMAIL_FROM=This email address is being protected from spambots. You need JavaScript enabled to view it.

# Email RCPT
EMAIL_TO=This email address is being protected from spambots. You need JavaScript enabled to view it.

You also need to edit the BVMs file. You can do it in Notepad but its possible that it will add some extra data that will cause issues. If you do use Notepad you want to make sure you don't hit enter or it will add exta characters that ESXi will not like. After the files are copied to the server I'll show you how to check for the extra characters.

The BVMs file needs to contain the names of the VM's that you want backed up. Each VM needs to be on its own line.

VM1
VM2
VM3

Now that the script and the bvms file is edited it's time to copy the files to the server. Using SCP copy the files to your ESXi server. To make things easy I just copied the file to the root "/" file system.

SCP Screen

Next use an SSH application like Putty to access your ESXi console remotely. After you login type "cat bvms". The image below shows how the file should look if there are no errors in it.

SSH vbs cat

Now that you have verified that your bvms file is correct you need to make sure that the script has executable permissions. You do this by typing chmod +x ghettoVCB.sh.

Now you're ready to run the script. To run the script type ./ghettoVCB.sh -f bvms, the backup should begin to run. 

Once you can run the script from the command prompt, see my article on Scheduling your ESXi Backup to enable full backup automation.

Tech Stocks


Warning: Invalid argument supplied for foreach() in /home/sohowe5/public_html/tonystech.com/modules/mod_rokstock/lib/googlestock.class.php on line 71

Donations

If you like the site and feel the need to donate to help support the site, you can do it here.



Login Form