GhettoVCB: Difference between revisions

From Leo's Notes
This page was last edited on 16 July 2017, at 00:24.
Created page with "There's a script called GhettoVCB which creates and restores backups using snapshots. On a linux machine: # wget ghettoVCB-master.zip # scp ghettoVCB-master.zip root@esxi..."
 
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
There's a script called GhettoVCB which creates and restores backups using snapshots.  
ghettoVCB is a script that allows VMware ESXi hosts to backup virtual machines using snapshots without requiring the guest to shut down.


The drawback with this script is that it is unable to back up guests with existing snapshots.


On a linux machine:
== Installation ==
# wget ghettoVCB-master.zip
Get the script from their GitHub repository:
# scp ghettoVCB-master.zip root@esxi:/
* https://github.com/lamw/ghettoVCB


You may either install it using their .vib package, or save the script somewhere accessible by the ESXi server.


On the ESXi server:
== Usage ==
Create a datastore (either NFS or disk) that you will backup to. For my usual use-case, I normally create a NFS share for backups which is also where I place the ghettoVCB script and configuration as well.


~ # unzip ghettoVCB-master.zip
{{highlight|lang=terminal|code=
Archive:  ghettoVCB-master.zip
## /data/vm is exported for the ESXi server.
    creating: ghettoVCB-master/
## Edit the ghettoVCB.conf as desired (optional)
  inflating: ghettoVCB-master/README
## The backup_vms file contains all the VMs I wish to back up (see below)
  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
~ # rm ghettoVCB-master.zip
~ # cd ghettoVCB-master/
/ghettoVCB-master # chmod +x ghettoVCB.sh
/ghettoVCB-master # chmod +x ghettoVCB-restore.sh
/ghettoVCB-master # ls
README
ghettoVCB-restore.sh
ghettoVCB-restore_vm_restore_configuration_template
ghettoVCB-vm_backup_configuration_template
ghettoVCB.conf
ghettoVCB.sh
 
/ghettoVCB-master # vi ghettoVCB.sh
  (ensure that VM_BACKUP_VOLUME is set to your backup volume. eg: /vmfs/volumes/backups/)
/ghettoVCB-master # ./ghettoVCB.sh -m "CentOS6"


   
leo@nas:/data/vm% ls
backup_vms esxi-backup/  ghettoVCB.conf  ghettoVCB.sh*


[[Category:ESXi]]
leo@nas:/data/vm% cat backup_vms
CentOS 7 Web
Fedora Compute
}}
 
To back up a machine named 'CentOS 7', run:
{{highlight|lang=terminal|code=
[root@server:/vmfs/volumes/ee8ff6f0-af4dbc98] sh ./ghettoVCB.sh -m "CentOS 7"
}}
 
However, if you want to backup a set of virtual machines, create a text file containing the name of each virtual machine you wish to back up and then run:
{{highlight|lang=terminal|code=
[root@server:/vmfs/volumes/ee8ff6f0-af4dbc98] sh ./ghettoVCB.sh -f backup_vms
}}
 
== Scheduled Backups ==
You can add a cronjob on the ESXi server to automatically run ghettoVCB.
 
{{highlight|lang=terminal|code=
# vi /var/spool/cron/crontabs/root
## Add the job. Run at 5AM every Sunday
0    5    *  *  0  /vmfs/volumes/nas-vm/ghettoVCB.sh -g /vmfs/volumes/nas-vm/ghettoVCB.conf -f /vmfs/volumes/nas-vm/backup_vms
}}
 
You may want to make this persistent by editing the startup script to insert this job.
{{highlight|lang=terminal|code=
# vi /etc/rc.local.d/local.sh
## Add the following above exit 0
/bin/echo "0    5    *  *  0  /vmfs/volumes/nas-vm/ghettoVCB.sh -g /vmfs/volumes/nas-vm/ghettoVCB.conf -f /vmfs/volumes/nas-vm/backup_vms" >>  /var/spool/cron/crontabs/root
}}
 
You shouldn't need to stop/start crond, but in case you do:
{{highlight|lang=terminal|code=
/bin/kill $(cat /var/run/crond.pid)
/bin/crond
}}
 
 
 
 
[[Category:VMWare_ESXi]]

Latest revision as of 00:24, 16 July 2017

ghettoVCB is a script that allows VMware ESXi hosts to backup virtual machines using snapshots without requiring the guest to shut down.

The drawback with this script is that it is unable to back up guests with existing snapshots.

Installation

Get the script from their GitHub repository:

You may either install it using their .vib package, or save the script somewhere accessible by the ESXi server.

Usage

Create a datastore (either NFS or disk) that you will backup to. For my usual use-case, I normally create a NFS share for backups which is also where I place the ghettoVCB script and configuration as well.

## /data/vm is exported for the ESXi server.
## Edit the ghettoVCB.conf as desired (optional)
## The backup_vms file contains all the VMs I wish to back up (see below)

leo@nas:/data/vm% ls
backup_vms  esxi-backup/  ghettoVCB.conf  ghettoVCB.sh*

leo@nas:/data/vm% cat backup_vms
CentOS 7 Web
Fedora Compute

To back up a machine named 'CentOS 7', run:

[root@server:/vmfs/volumes/ee8ff6f0-af4dbc98] sh ./ghettoVCB.sh -m "CentOS 7"

However, if you want to backup a set of virtual machines, create a text file containing the name of each virtual machine you wish to back up and then run:

[root@server:/vmfs/volumes/ee8ff6f0-af4dbc98] sh ./ghettoVCB.sh -f backup_vms

Scheduled Backups

You can add a cronjob on the ESXi server to automatically run ghettoVCB.

# vi /var/spool/cron/crontabs/root
## Add the job. Run at 5AM every Sunday
0    5    *   *   0   /vmfs/volumes/nas-vm/ghettoVCB.sh -g /vmfs/volumes/nas-vm/ghettoVCB.conf -f /vmfs/volumes/nas-vm/backup_vms

You may want to make this persistent by editing the startup script to insert this job.

# vi /etc/rc.local.d/local.sh
## Add the following above exit 0
/bin/echo "0    5    *   *   0   /vmfs/volumes/nas-vm/ghettoVCB.sh -g /vmfs/volumes/nas-vm/ghettoVCB.conf -f /vmfs/volumes/nas-vm/backup_vms" >>  /var/spool/cron/crontabs/root

You shouldn't need to stop/start crond, but in case you do:

/bin/kill $(cat /var/run/crond.pid)
/bin/crond