User Tools

Site Tools


archive:vmware_backup

VMware Esxi XSI Backup

Prerequisites

  1. Download and deploy XSI backup on the Esxi host
  2. Add a cronjob for the backup script

Download And Deploy XSI Backup

XSI backup is a free tool that can do hot and cold backups of your VMware guest's. You can grap a copy here: XSI Backup

Note In order to be able to do warm / hot backups vmware tools needs to be installed on the guests.

Once downloaded you should scp it to your Esxi host into a directory called “xsi-dir” on the first datastore.

cd /vmfs/volumes/datastore1
mkdir xsi-dir

Next scp the XSI backup program to the directory you created above and unzip it.

the contents of the folder should look like this:

EULA
README.txt
backup.sh
bin
conf
request.key
src
xsibackup

Next set some permissions.

chmod -R 0700 xsibackup*
chmod -R 0700 bin
chmod -R 0700 src

Right moving on.

First create a backup script containing the VMware guests you want to back up.

vi /vmfs/volumes/datastore1/backup.sh

In backup.sh change and or add more machines the names “vmguest1,vmguest2,vmguest3” should be replaced with real guest names running on your host.

The contents of backup.sh (modify to your needs). Note the entry called “backup-point” can be a NFS share and does not have to be local.

/vmfs/volumes/datastore1/xsi-dir/xsibackup --date-dir=no --backup-room=200 --backup-point=/vmfs/volumes/vmbackup --backup-type=custom --backup-vms="vmguest1,vmguest2,vmguest3"

Make backup.sh executable

chmod 777 /vmfs/volumes/datastore1/xsi-dir/backup.sh

Note I suggest testing this by running it manually to see if things works as inteded.

Add Backup To Cron

Adding the backup script to cron is a bit different than your normal *nix crontab for a couple of reasons.

  1. The crontab is not located in /etc
  2. It is beeing whiped on every reboot

In order to add the backup script to cron edit the following file which is esxi's crontab file.

vi /var/spool/cron/crontabs/root

Add a suitable entry here's an example:

* 22 * * 0 /vmfs/volumes/datastore1-DONT-USE-FOR-VMS/xsi-dir/backup.sh 2>&1

Next we need to restart cron. We do this by killing the cron pid.

cat /var/run/crond.pid

Next kill the pid for cron where “12345” is the pid we got from the command above.

kill 12345

Now we need to start up cron and make sure it is backed up.

/usr/lib/vmware/busybox/bin/busybox crond
auto-backup.sh

Note As mentioned this will not survive a reboot, so on order to fix this we need to “inject” the crontab entry upon every reboot. This can be accomplished like this.

vi /etc/rc.local.d/local.sh

At the bottom of this script add the following lines. This will make sure the entry gets injected into cron upon reboot.

/bin/kill $(cat /var/run/crond.pid)
/bin/echo '* 22 * * 0 /vmfs/volumes/datastore1/xsi-dir/backup.sh 2>&1' >> /var/spool/cron/crontabs/root
/bin/busybox crond
archive/vmware_backup.txt · Last modified: 24/11/2023 12:48 by Allan