January 17, 2022

VMware: Backing up your ESX Configuration/VMX files

This is a quick/easy/down/dirty way of backing up your ESX configuration information.

You’ll need to add a cron job, and create a script to run that cron job.

Here’s the script that I used to mount a Windows share, copy the files over, and then unmount the Windows share (I saved it in /root as backup.sh:
mount -t smbfs //windowsserver/sharename /mountpoint -o username=user/DOMAIN,password=password

cd /mountpoint/ESX_Backups/

rm -rf ./old.$HOSTNAME/

mv ./$HOSTNAME/ ./old.$HOSTNAME/


cd /

cp -duR /etc/ /mountpoint/ESX_Backups/$HOSTNAME/

cp -duR /home/ /myappro/ESX_Backups/$HOSTNAME/

umount /mountpoint
For this to work properly, in your Windows share, you will already need to have a folder named ESX_Backups (it is case sensitive).

You’ll need to figure out where you mount point is going to be, where you can mount the Windows share to.

Also, make sure you do a chmod 700 backup.sh so this file will be executable.

By copying all files in /etc/ and /home/ I get all ESX config files, and VM config files. You could modify this to be more specific, but I didn’t see the need to. I like the KISS method.

Now I made a cron entry like this:
10 23 * * * * root /root/backup.sh > /dev/null 2>&1
And saved it as /etc/cron.d/backupcron.sh, with a chmod 500 for it.

Simple, effective, & very little time to implement. And now I have the past 2 days worth of ESX and VM config.

One thought on “VMware: Backing up your ESX Configuration/VMX files

  1. I’m using 3.0.x (from 2.5.x many months ago.) I’m trying a variation of your script (since it looked VERY similar to one I was using in 2.5.x) and if I put #!/bin/bash at the beginning of the script, I get a “: bad interpreter: No such file or directory” error. If I remove it, I get “14607: session setup failed: ERRDOS – ERRnoaccess (Access denied.) SMB connection failed”. I tried adding “esxcfg-firewall –enableService smbClient” to the beginning of the script but get errors as well. I had one of my UNIX guys look at it and he’s stumped. Any ideas?
    darren @ debaillon . org

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.