Difference between revisions of "ESXi - ghettoVCB"

From The TinkerNet Wiki
Jump to navigation Jump to search
(Created page with "== Installation == === Install ghettoVCB === #[http://www.virtubytes.com/2017/04/21/enable-ssh-vmware-esxi-6-5/ SSH (as root) into the machine] #Create a Utilities folder on...")
 
 
(21 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Installation ==
+
[https://github.com/lamw/ghettoVCB ghettoVCB on GitHub]
=== Install ghettoVCB ===
+
 
 +
==Installation==
 +
===Install ghettoVCB===
  
 
#[http://www.virtubytes.com/2017/04/21/enable-ssh-vmware-esxi-6-5/ SSH (as root) into the machine]
 
#[http://www.virtubytes.com/2017/04/21/enable-ssh-vmware-esxi-6-5/ SSH (as root) into the machine]
 
#Create a Utilities folder on an existing datastore
 
#Create a Utilities folder on an existing datastore
#*<code>mkdir "/vmfs/volumes/Alpha/Utility_Room/"</code>
+
#*<code>mkdir "/vmfs/volumes/Admin/Utilities/"</code>
 
#*(This exact location is specific to my testbed server...)
 
#*(This exact location is specific to my testbed server...)
 
#*'''Remember this location...'''  It'll be very useful...
 
#*'''Remember this location...'''  It'll be very useful...
 
#switch to this folder
 
#switch to this folder
#*<code>cd "/vmfs/volumes/Alpha/Utility_Room/"</code>
+
#*<code>cd "/vmfs/volumes/Admin/Utilities/"</code>
 
#download ghettoVCB
 
#download ghettoVCB
#*<s>wget https://github.com/lamw/ghettoVCB/archive/master.zip</s>
+
#*<s>wget <nowiki>https://github.com/lamw/ghettoVCB/archive/master.zip</nowiki></s>
 
#**(wget doesn't seem to like https...)
 
#**(wget doesn't seem to like https...)
 
#*''<small><sub>wget <nowiki>http://web.tinkernow.net/otherfiles/ghettoVCB.zip</nowiki></sub></small>''
 
#*''<small><sub>wget <nowiki>http://web.tinkernow.net/otherfiles/ghettoVCB.zip</nowiki></sub></small>''
 
#**''<sup><small>(inside my local network...)</small></sup>''
 
#**''<sup><small>(inside my local network...)</small></sup>''
#*wget http://tinker.farted<nowiki/>.net/otherfiles/ghettoVCB.zip
+
#*wget <nowiki>http://tinker.farted.net/otherfiles/ghettoVCB.zip</nowiki>
#**(a copy accessible to wge<nowiki/>t without https)
+
#**(a copy accessible to wget without https)
 
#Unpack & rename ghettoVCB
 
#Unpack & rename ghettoVCB
 
#*<code>unzip ghettoVCB.zip</code>
 
#*<code>unzip ghettoVCB.zip</code>
Line 22: Line 24:
 
#*<code>cd ghettoVCB</code>
 
#*<code>cd ghettoVCB</code>
 
#Install it!
 
#Install it!
#*<code>esxcli software vib install -v "/vmfs/volumes/Alpha/Utility_Room/ghettoVCB/vghetto-ghettoVCB.vib" -f</code>
+
#*<code>esxcli software vib install -v "/vmfs/volumes/Admin/Utilities/ghettoVCB/vghetto-ghettoVCB.vib" -f</code>
  
 
<sup><small>Have ya noticed the usefulness of remembering "/vmfs/volumes/Alpha/Utility_Room/" yet?<br /></small></sup>
 
<sup><small>Have ya noticed the usefulness of remembering "/vmfs/volumes/Alpha/Utility_Room/" yet?<br /></small></sup>
  
=== Create a Backup folder on the datastore ===
+
===Create a Backup folder on the datastore===
<code>mkdir "/vmfs/volumes/Beta/BACKUPS"</code>
+
 
 +
'''Not needed if your datastores are set up in the "standard" way...'''
 +
 
 +
<s><code>mkdir "/vmfs/volumes/Backups"</code></s>
  
 
ghettoVCB will create subfolders for each VM you backup inside this folder.
 
ghettoVCB will create subfolders for each VM you backup inside this folder.
  
== Configuration ==
+
==Configuration==
  
 
<code>vi ghettoVCB.conf</code><syntaxhighlight lang="bash">
 
<code>vi ghettoVCB.conf</code><syntaxhighlight lang="bash">
Line 75: Line 80:
 
Sadly, vi seems to be the only editor available under ESXi.  Somebody remind my to write up a tutorial for using it... For now, look [[ESXi - ghettoVCB#Using vi|here]].
 
Sadly, vi seems to be the only editor available under ESXi.  Somebody remind my to write up a tutorial for using it... For now, look [[ESXi - ghettoVCB#Using vi|here]].
  
== Testing ==
+
==Testing==
  
 
I'm using a VM called "Manager" as my test...
 
I'm using a VM called "Manager" as my test...
Line 89: Line 94:
 
When you see: "'''info: ###### Final status: All VMs backed up OK! ######'''", congratulations, you have a manual backup.
 
When you see: "'''info: ###### Final status: All VMs backed up OK! ######'''", congratulations, you have a manual backup.
  
=== Restoring a VM ===
+
===Restoring a VM===
  
 
Edit the input file for <code>ghettoVCB-restore</code>
 
Edit the input file for <code>ghettoVCB-restore</code>
Line 122: Line 127:
 
<code>./ghettoVCB-restore.sh -c vms_to_restore</code>
 
<code>./ghettoVCB-restore.sh -c vms_to_restore</code>
  
== Customization ==
+
==Customization==
  
=== Set up a cron job ===
+
===Set up a cron job===
 
I'll have to properly detail this yet...
 
I'll have to properly detail this yet...
  
Meanwhile:  [[Add cron Job to VMware ESX/ESXi]]
+
Meanwhile:  [[ESXi - Add cron Job|Add cron Job to VMware ESX/ESXi]]
  
 
Here's an ugly example based on how I got it working here...
 
Here's an ugly example based on how I got it working here...
Line 135: Line 140:
 
*<code>vi /var/spool/cron/crontabs/root</code>
 
*<code>vi /var/spool/cron/crontabs/root</code>
 
**Add the following at the bottom:
 
**Add the following at the bottom:
**<code>1    2    *   *   *   "/vmfs/volumes/Alpha/Utility_Room/ghettoVCB/ghettoVCB.sh" -m "Manager" -g "/vmfs/volumes/Alpha/Utility_Room/ghettoVCB/ghettoVCB.conf"</code>
+
**<code>1    2    *   *   *   "/vmfs/volumes/Admin/Utilities/ghettoVCB/ghettoVCB.sh" -m "Manager" -g "/vmfs/volumes/Admin/Utilities/ghettoVCB/ghettoVCB.conf"</code>
 
*<code>/usr/lib/vmware/busybox/bin/busybox crond</code>
 
*<code>/usr/lib/vmware/busybox/bin/busybox crond</code>
 
**This starts cron back up
 
**This starts cron back up
Line 141: Line 146:
 
**The following lines added '''BEFORE''' the <code>exit 0</code> line tell ESXi to do the modification to <code>crontab</code> at boot time:
 
**The following lines added '''BEFORE''' the <code>exit 0</code> line tell ESXi to do the modification to <code>crontab</code> at boot time:
 
**<code>/bin/kill $(cat /var/run/crond.pid)</code>
 
**<code>/bin/kill $(cat /var/run/crond.pid)</code>
**<code>/bin/echo '1    2    *   *   *   "/vmfs/volumes/Alpha/Utility_Room/ghettoVCB/ghettoVCB.sh" -g "/vmfs/volumes/Alpha/Utility_Room/ghettoVCB/ghettoVCB.conf" -m "Manager"' >> /var/spool/cron/crontabs/root</code>
+
**<code>/bin/echo '1    2    *   *   *   "/vmfs/volumes/Admin/Utilities/ghettoVCB/ghettoVCB.sh" -g "/vmfs/volumes/Admin/Utilities/ghettoVCB/ghettoVCB.conf" -m "Manager"' >> /var/spool/cron/crontabs/root</code>
 
**<code>/usr/lib/vmware/busybox/bin/busybox crond</code>
 
**<code>/usr/lib/vmware/busybox/bin/busybox crond</code>
 
*<code>/sbin/auto-backup.sh</code>
 
*<code>/sbin/auto-backup.sh</code>
Line 147: Line 152:
  
  
=== Simplifying manual backups ===
+
===Simplifying manual backups===
<code>cd /vmfs/volumes/Alpha/Utility_Room/ghettoVCB/</code>
+
 
 +
'''NOTE:''' Need to do some sort of error handling. ATM, if you try to backup a VM that doesn't exist, it fails silently.
 +
 
 +
<code>cd /vmfs/volumes/Admin/Utilities/ghettoVCB/</code>
 +
 
 +
<code>vi backup.sh</code>
  
 +
#!/bin/sh                                                                         
 +
                                                                                   
 +
export PATH=/bin:/sbin
 +
 
  for VMName in "$@"
 
  for VMName in "$@"
 
  do
 
  do
Line 156: Line 170:
 
  echo "###############################"
 
  echo "###############################"
 
  echo
 
  echo
  /vmfs/volumes/Alpha/Utility_Room/ghettoVCB/ghettoVCB.sh \
+
     -g /vmfs/volumes/Alpha/Utility_Room/ghettoVCB/ghettoVCB.conf \
+
logger "ghettoVCB/backup.sh is backing up "$VMName"."
 +
 +
  /vmfs/volumes/Admin/Utilities/ghettoVCB/ghettoVCB.sh \
 +
     -g /vmfs/volumes/Admin/Utilities/ghettoVCB/ghettoVCB.conf \
 
     -m $VMName
 
     -m $VMName
 +
 +
logger "ghettoVCB/backup.sh is finished backing up "$VMName"."
 +
 
  echo
 
  echo
 
  echo "###############################"
 
  echo "###############################"
Line 164: Line 184:
 
  echo "###############################"
 
  echo "###############################"
 
  done
 
  done
 +
 +
logger "ghettoVCB/backup.sh finished"
 +
 +
<code>chmod +x backup.sh</code>
  
 
Then you can do fun things like:
 
Then you can do fun things like:
Line 173: Line 197:
 
(Now find out how to put it directly in the execution path...)
 
(Now find out how to put it directly in the execution path...)
  
== Tricks with ghettoVCB backups ==
+
====Running a backup remotely====
 +
Note:  You'll need to have SSHed into the server previously from the machine you want to run this command from.  (SSH is a strange beast... It REALLY wants to set up stuff on your local machine for verification. Whoda Thunkit)
 +
 
 +
<code>ssh root@ESXiServer "/vmfs/volumes/Admin/Utilities/ghettoVCB/backup.sh VMname"</code>
 +
 
 +
===Simplifying Clone Deployment===
 +
 
 +
<code>cd /vmfs/volumes/Admin/Utilities/ghettoVCB/</code>
 +
 
 +
<code>vi clone.sh</code>
 +
 
 +
#!/bin/sh                                                               
 +
 +
export PATH=/bin:/sbin
 +
 +
for VMName in "$@"
 +
do
 +
echo "###############################"
 +
echo "#  Creating "$VMName
 +
echo "###############################"
 +
echo
 +
 +
logger "ghettoVCB/clone.sh is creating "$VMName" from CloneMe."
 +
 +
echo "/vmfs/volumes/Admin/CloneMe/CloneMe-Mint-19.3/CloneMe-Mint-19.3-0;/vmfs/volumes/Admin;1;"$VMName > CloneIt
 +
/vmfs/volumes/Admin/Utilities/ghettoVCB/ghettoVCB-restore.sh -c CloneIt
 +
 +
logger "ghettoVCB/clone.sh "$VMName" finished"
 +
 +
echo
 +
echo "###############################"
 +
echo "# "$VMName" is created"
 +
echo "###############################"
 +
done
 +
 
 +
<code>chmod +x clone.sh</code>
 +
 
 +
Then you can do fun things like:
 +
 
 +
<code>./clone.sh Manager WebServer Automation Download</code>
 +
 
 +
& all the VMs will be created as clones of '''CloneMe'''.
 +
 
 +
====Thoughts====
 +
 
 +
*Need to create a '''CloneMe''' creator script.
 +
**Multiple '''CloneMes''' would be good...
 +
**Duplicate <code>ghetoVCB.conf</code> to <code>CloneMe.conf</code>
 +
***Add in,
 +
****<code>VM_BACKUP_VOLUME="/vmfs/volumes/Admin/CloneMe"</code>
 +
****<code>VM_BACKUP_DIR_NAMING_CONVENTION="0"</code>
 +
***Then:
 +
****<code>./ghettoVCB.sh -g ./CloneMe.conf -m CloneMe-Mint-19.3</code>
 +
 
 +
*Need a way to tell <code>clone.sh</code> which '''CloneMe''' to use...
 +
**This particular rabbit hole has forced the realisation that '''sh''' as implemented in ESXi is a poor substitute for bash.
 +
**The [[GhettoVCB - clone.sh BASH Script|script]] to provide a menu of available '''CloneMe'''s in bash is quite elegant.
 +
**The [[GhettoVCB - clone.sh Script|script]] to do the same in ESXis '''sh''' is a fugly mess of hard-coded information.
 +
*&, of course, where to actually put the clone.
 +
**(see comments just above about shell implementation...  :( )
 +
 
 +
===Simplifying Restoration of a Backup===
 +
Coming Soon<sup>TM</sup>...
 +
 
 +
==Tricks with ghettoVCB backups==
  
=== Cloning preconfigured VMs ===
+
===Cloning preconfigured VMs===
 
Yes, this IS a good way to duplicate preconfigured VMs.
 
Yes, this IS a good way to duplicate preconfigured VMs.
  
=== Moving & copying VMs to another physical machine ===
+
===Moving & copying VMs to another physical machine===
 
Duplicate the backup onto the destination machine.
 
Duplicate the backup onto the destination machine.
  
Line 198: Line 286:
 
**Now you can simply restore it as normal.
 
**Now you can simply restore it as normal.
  
== Still to be done ==
+
==Still to be done==
  
 
*Look into partial backups.  i.e.: select specific drives on a per-VM basis
 
*Look into partial backups.  i.e.: select specific drives on a per-VM basis
  
== Backing up (or copying/moving) the Backups ==
+
==Backing up (or copying/moving) the Backups==
 
'''<big>This is a Work In Progress</big>'''
 
'''<big>This is a Work In Progress</big>'''
  
Line 214: Line 302:
 
**Using NFS
 
**Using NFS
 
***ghettoVCB has this built-in, but you'll need an NFS server available full time.
 
***ghettoVCB has this built-in, but you'll need an NFS server available full time.
 +
**<span style="color:green">'''Using SCP'''</span>
 +
***First things first...  Enable outgoing SCP on the host. (SSH Client)
 +
****[https://4sysops.com/archives/how-to-open-and-close-firewall-ports-on-vmware-esxi-hosts/ How to Open and Close Firewall Ports on vmWare ESXi Hosts]
 +
***Next, change to your backups folder.
 +
****<code>cd /vmfs/volumes/Backup</code>
 +
***Then, SCP your backup to another machine.
 +
****<code>scp -r Backup user@machine:destination</code>
 
*Using a hot-swap drive
 
*Using a hot-swap drive
 
**If your server has hot-swap bays, it's a simple matter of copying your backups to a datastore located on one of the hot-swappable drives &, well, hot-swapping it.
 
**If your server has hot-swap bays, it's a simple matter of copying your backups to a datastore located on one of the hot-swappable drives &, well, hot-swapping it.
Line 229: Line 324:
 
****<code><s>cp -R /vmfs/volumes/Beta/BACKUPS/* /vmfs/volumes/VMFS-Backups/</s></code>
 
****<code><s>cp -R /vmfs/volumes/Beta/BACKUPS/* /vmfs/volumes/VMFS-Backups/</s></code>
  
== Reference Links ==
+
==Reference Links==
  
 
*The original package on GitHub
 
*The original package on GitHub
Line 240: Line 335:
 
*[https://blog.kingj.net/2016/07/03/how-to/backing-up-vmware-esxi-vms-with-ghettovcb/ Backing up VMware ESXi VMs with ghettoVCB]
 
*[https://blog.kingj.net/2016/07/03/how-to/backing-up-vmware-esxi-vms-with-ghettovcb/ Backing up VMware ESXi VMs with ghettoVCB]
  
=== Using vi ===
+
===Using vi===
  
 
*[https://www.cs.colostate.edu/helpdocs/vi.html Basic vi Commands] (CSU)
 
*[https://www.cs.colostate.edu/helpdocs/vi.html Basic vi Commands] (CSU)
 
*[https://www.ccsf.edu/Pub/Fac/vi.html UNIX:  vi Editor] (City College of SF)
 
*[https://www.ccsf.edu/Pub/Fac/vi.html UNIX:  vi Editor] (City College of SF)
*[https://www.guru99.com/the-vi-editor.html VI Text Editor with Commands: Linux/Unix Tutorial] (Guru99)
+
*VI Text Editor with Commands: Linux/Unix Tutorial (Guru99)
 +
** Link removed because Guru99 apparently no longer wants traffic

Latest revision as of 00:46, 23 August 2023

ghettoVCB on GitHub

Installation

Install ghettoVCB

  1. SSH (as root) into the machine
  2. Create a Utilities folder on an existing datastore
    • mkdir "/vmfs/volumes/Admin/Utilities/"
    • (This exact location is specific to my testbed server...)
    • Remember this location... It'll be very useful...
  3. switch to this folder
    • cd "/vmfs/volumes/Admin/Utilities/"
  4. download ghettoVCB
    • wget https://github.com/lamw/ghettoVCB/archive/master.zip
      • (wget doesn't seem to like https...)
    • wget http://web.tinkernow.net/otherfiles/ghettoVCB.zip
      • (inside my local network...)
    • wget http://tinker.farted.net/otherfiles/ghettoVCB.zip
      • (a copy accessible to wget without https)
  5. Unpack & rename ghettoVCB
    • unzip ghettoVCB.zip
    • mv ghettoVCB-master ghettoVCB
  6. switch to the new folder
    • cd ghettoVCB
  7. Install it!
    • esxcli software vib install -v "/vmfs/volumes/Admin/Utilities/ghettoVCB/vghetto-ghettoVCB.vib" -f

Have ya noticed the usefulness of remembering "/vmfs/volumes/Alpha/Utility_Room/" yet?

Create a Backup folder on the datastore

Not needed if your datastores are set up in the "standard" way...

mkdir "/vmfs/volumes/Backups"

ghettoVCB will create subfolders for each VM you backup inside this folder.

Configuration

vi ghettoVCB.conf

VM_BACKUP_VOLUME="/vmfs/volumes/Beta/BACKUPS"
DISK_BACKUP_FORMAT=thin
VM_BACKUP_ROTATION_COUNT=3
POWER_VM_DOWN_BEFORE_BACKUP=0
ENABLE_HARD_POWER_OFF=0
ITER_TO_WAIT_SHUTDOWN=3
POWER_DOWN_TIMEOUT=5
ENABLE_COMPRESSION=0
VM_SNAPSHOT_MEMORY=0
VM_SNAPSHOT_QUIESCE=0
ALLOW_VMS_WITH_SNAPSHOTS_TO_BE_BACKEDUP=0
ENABLE_NON_PERSISTENT_NFS=0
UNMOUNT_NFS=0
NFS_SERVER=
NFS_VERSION=
NFS_MOUNT=
NFS_LOCAL_NAME=
NFS_VM_BACKUP_DIR=
SNAPSHOT_TIMEOUT=15
EMAIL_ALERT=0
EMAIL_LOG=0
EMAIL_SERVER=
EMAIL_SERVER_PORT=25
EMAIL_DELAY_INTERVAL=1
EMAIL_USER_NAME=
EMAIL_USER_PASSWORD=
EMAIL_TO=
EMAIL_ERRORS_TO=
EMAIL_FROM=
WORKDIR_DEBUG=0
VM_SHUTDOWN_ORDER=
VM_STARTUP_ORDER=

(just an example...)

You may note that there are A LOT of things you can configure here.

The important one here is the first line where it points to your backup folder.

Sadly, vi seems to be the only editor available under ESXi. Somebody remind my to write up a tutorial for using it... For now, look here.

Testing

I'm using a VM called "Manager" as my test...

./ghettoVCB.sh -g ./ghettoVCB.conf -m "Manager" -d dryrun

If you see "info: ###### Final status: OK, only a dryrun. ######", it's OK.

Now you can do a real backup...

./ghettoVCB.sh -g ./ghettoVCB.conf -m "Manager"

When you see: "info: ###### Final status: All VMs backed up OK! ######", congratulations, you have a manual backup.

Restoring a VM

Edit the input file for ghettoVCB-restore

vi vms_to_restore

#"<DIRECTORY or .TGZ>;<DATASTORE_TO_RESTORE_TO>;<DISK_FORMAT_TO_RESTORE>;<OPTIONAL_RESTORED_VM_DISPLAY_NAME>"
# DISK_FORMATS
# 1 = zeroedthick
# 2 = 2gbsparse
# 3 = thin
# 4 = eagerzeroedthick
### To restore the VM back to its original name (DELETE the original first!):
#/vmfs/volumes/Beta/BACKUPS/Manager/Manager-2019-09-08_21-01-00;/vmfs/volumes/Alpha;1
### To duplicate the VM under a new name:
/vmfs/volumes/Beta/BACKUPS/Manager/Manager-2019-09-08_21-01-00;/vmfs/volumes/Alpha;1;FooBar

(just an example...

I'm restoring a backup of "Manager", but renaming it to "FooBar" in the process. This is a potential way to rapidly duplicate preconfigured VMs.)

The "/vmfs/volumes/Beta/BACKUPS/Manager/Manager-2019-09-08_21-01-00" part of the non-commented line is the name of the actual backup being restored.

The "/vmfs/volumes/Alpha" part is the folder containing the original VM. (or, at least, the folder you want to restore to...)

If you are restoring to the original VM, delete the original VM first:

rm -R /vmfs/volumes/Alpha/Manager

(do it in the GUI...)

Restore the VM:

./ghettoVCB-restore.sh -c vms_to_restore

Customization

Set up a cron job

I'll have to properly detail this yet...

Meanwhile: Add cron Job to VMware ESX/ESXi

Here's an ugly example based on how I got it working here...

  • /bin/kill $(cat /var/run/crond.pid)
    • This stops cron
  • vi /var/spool/cron/crontabs/root
    • Add the following at the bottom:
    • 1    2    *   *   *   "/vmfs/volumes/Admin/Utilities/ghettoVCB/ghettoVCB.sh" -m "Manager" -g "/vmfs/volumes/Admin/Utilities/ghettoVCB/ghettoVCB.conf"
  • /usr/lib/vmware/busybox/bin/busybox crond
    • This starts cron back up
  • vi /etc/rc.local.d/local.sh
    • The following lines added BEFORE the exit 0 line tell ESXi to do the modification to crontab at boot time:
    • /bin/kill $(cat /var/run/crond.pid)
    • /bin/echo '1    2    *   *   *   "/vmfs/volumes/Admin/Utilities/ghettoVCB/ghettoVCB.sh" -g "/vmfs/volumes/Admin/Utilities/ghettoVCB/ghettoVCB.conf" -m "Manager"' >> /var/spool/cron/crontabs/root
    • /usr/lib/vmware/busybox/bin/busybox crond
  • /sbin/auto-backup.sh
    • Ensures that the changes to local.sh get written back to the boot thumbdrive.


Simplifying manual backups

NOTE: Need to do some sort of error handling. ATM, if you try to backup a VM that doesn't exist, it fails silently.

cd /vmfs/volumes/Admin/Utilities/ghettoVCB/

vi backup.sh

#!/bin/sh                                                                           
                                                                                   
export PATH=/bin:/sbin

for VMName in "$@"
do
echo "###############################"
echo "#  Backing up "$VMName
echo "###############################"
echo

logger "ghettoVCB/backup.sh is backing up "$VMName"."

/vmfs/volumes/Admin/Utilities/ghettoVCB/ghettoVCB.sh \
   -g /vmfs/volumes/Admin/Utilities/ghettoVCB/ghettoVCB.conf \
   -m $VMName

logger "ghettoVCB/backup.sh is finished backing up "$VMName"."

echo
echo "###############################"
echo "# "$VMName" is backed up"
echo "###############################"
done

logger "ghettoVCB/backup.sh finished"

chmod +x backup.sh

Then you can do fun things like:

./backup.sh Manager WebServer Automation Download

& all the VMs will get backed up.

(Now find out how to put it directly in the execution path...)

Running a backup remotely

Note: You'll need to have SSHed into the server previously from the machine you want to run this command from. (SSH is a strange beast... It REALLY wants to set up stuff on your local machine for verification. Whoda Thunkit)

ssh root@ESXiServer "/vmfs/volumes/Admin/Utilities/ghettoVCB/backup.sh VMname"

Simplifying Clone Deployment

cd /vmfs/volumes/Admin/Utilities/ghettoVCB/

vi clone.sh

#!/bin/sh                                                                

export PATH=/bin:/sbin

for VMName in "$@"
do
echo "###############################"
echo "#  Creating "$VMName
echo "###############################"
echo

logger "ghettoVCB/clone.sh is creating "$VMName" from CloneMe."

echo "/vmfs/volumes/Admin/CloneMe/CloneMe-Mint-19.3/CloneMe-Mint-19.3-0;/vmfs/volumes/Admin;1;"$VMName > CloneIt
/vmfs/volumes/Admin/Utilities/ghettoVCB/ghettoVCB-restore.sh -c CloneIt

logger "ghettoVCB/clone.sh "$VMName" finished"

echo
echo "###############################"
echo "# "$VMName" is created"
echo "###############################"
done

chmod +x clone.sh

Then you can do fun things like:

./clone.sh Manager WebServer Automation Download

& all the VMs will be created as clones of CloneMe.

Thoughts

  • Need to create a CloneMe creator script.
    • Multiple CloneMes would be good...
    • Duplicate ghetoVCB.conf to CloneMe.conf
      • Add in,
        • VM_BACKUP_VOLUME="/vmfs/volumes/Admin/CloneMe"
        • VM_BACKUP_DIR_NAMING_CONVENTION="0"
      • Then:
        • ./ghettoVCB.sh -g ./CloneMe.conf -m CloneMe-Mint-19.3
  • Need a way to tell clone.sh which CloneMe to use...
    • This particular rabbit hole has forced the realisation that sh as implemented in ESXi is a poor substitute for bash.
    • The script to provide a menu of available CloneMes in bash is quite elegant.
    • The script to do the same in ESXis sh is a fugly mess of hard-coded information.
  • &, of course, where to actually put the clone.
    • (see comments just above about shell implementation... :( )

Simplifying Restoration of a Backup

Coming SoonTM...

Tricks with ghettoVCB backups

Cloning preconfigured VMs

Yes, this IS a good way to duplicate preconfigured VMs.

Moving & copying VMs to another physical machine

Duplicate the backup onto the destination machine.

  • On the Source machine:
    • change to the folder containing the backups of interest:
      • cd /vmfs/volumes/Beta/BACKUPS/Manager/
    • Create an archive of the backup set required:
      • tar c -z -f Manager.tgz Manager-2019-09-08_21-01-00
  • On the Destination machine:
    • change to the backups folder:
      • cd /vmfs/volumes/Beta/BACKUPS/
    • Create a destination:
      • mkdir Manager/
  • Move the archive to the backups folder on the destination machine (transport method of your choice...)
    • Enter the destination backup folder:
      • cd Manager
    • Extract the archive:
      • tar x -z -f Manager.tgz
    • Now you can simply restore it as normal.

Still to be done

  • Look into partial backups. i.e.: select specific drives on a per-VM basis

Backing up (or copying/moving) the Backups

This is a Work In Progress

  • Over the network
    • Using the web interface
      1. Sign into the machine with a web browser
      2. Select Storage
      3. Click "Datastore browser"
      4. Navigate to the backups
      5. Download them
    • Using NFS
      • ghettoVCB has this built-in, but you'll need an NFS server available full time.
    • Using SCP
  • Using a hot-swap drive
    • If your server has hot-swap bays, it's a simple matter of copying your backups to a datastore located on one of the hot-swappable drives &, well, hot-swapping it.
  • Using an external drive
    • Careful... This is a good way to mess up your server
      • Start here: USB Devices as VMFS Datastore in vSphere ESXi 6.0
      • An example sequence of commands used here:
        • /etc/init.d/usbarbitrator stop
        • ls /dev/disks/
          • My external drive (a 1TB WD My Passport Ultra)shows up as mpx.vmhba36
        • partedUtil mklabel /dev/disks/mpx.vmhba36\:C0\:T0\:L0 gpt
        • partedUtil setptbl /dev/disks/mpx.vmhba36\:C0\:T0\:L0 gpt "1 2048 1953455804 AA31E02A400F11DB9590000C2911D1B8 0"
        • vmkfstools -C vmfs5 -S VMFS-Backups /dev/disks/mpx.vmhba36\:C0\:T0\:L0:1
        • cp -R /vmfs/volumes/Beta/BACKUPS/* /vmfs/volumes/VMFS-Backups/

Reference Links

Using vi

  • Basic vi Commands (CSU)
  • UNIX: vi Editor (City College of SF)
  • VI Text Editor with Commands: Linux/Unix Tutorial (Guru99)
    • Link removed because Guru99 apparently no longer wants traffic