Modifying ghettoVCB to run on VMware ESXi 5.1

On September 14, 2012, in Technology, by Mike Waldron

UPDATE: William Lam has put out a 5.1 compatible version of ghettoVCB.  Click here to download!

I went to roll out a new VMware server, grabbing the fresh ESXi 5.1 build. When implementing ghettoVCB I observed that the /bin/busybox location is no longer valid, and that rc.local is no longer editable. Not only that, but because William Lam hasn’t yet updated ghettoVCB to include the 5.1 version, the script won’t even run on 5.1. Turns out the rc.local injection needs to happen in “/etc/rc.local.d/local.sh”.  Also, because busybox has moved you need to change the injection script as follows:

/bin/kill $(cat /var/run/crond.pid)
/bin/echo "0 6 * * 0 /vmfs/volumes/backups/ghettoVCB/ghettoVCB.sh -a > /vmfs/volumes/backups/Logs/backup.log" >> /var/spool/cron/crontabs/root
/usr/lib/vmware/busybox/bin/busybox crond  

And you need to place the script above in “/etc/rc.local.d/local.sh” versus the old “/etc/rc.local” file.

Additionally you’ll need to modify the version check part of ghettoVCB.sh as follows (see bold portion):

        ESX_VERSION=$(vmware -v | awk '{print $3}')
	if [[ "${ESX_VERSION}" == "5.0.0" ]] || [[ "${ESX_VERSION}" == "5.1.0" ]]; then
		VER=5
        elif [[ "${ESX_VERSION}" == "4.0.0" ]] || [[ "${ESX_VERSION}" == "4.1.0" ]]; then
                VER=4
        else
                ESX_VERSION=$(vmware -v | awk '{print $4}')
                if [[ "${ESX_VERSION}" == "3.5.0" ]] || [[ "${ESX_VERSION}" == "3i" ]]; then
                        VER=3
                else
                        echo "You're not running ESX(i) 3.5, 4.x, 5.x!"
                        exit 1
                fi
        fi

The above steps got ghettoVCB running for me on 5.1.
 
UPDATE: William Lam has put out a 5.1 compatible version of ghettoVCB.  Click here to download!


Tagged with:  

19 Responses to Modifying ghettoVCB to run on VMware ESXi 5.1

  1. Derek Shaw says:

    Thanks for posting this. Haven’t tested re-booting the esxi server yet (still doing time-trials with ghettoVCB to various nfs backup targets). But it all worked manually.

    Does one still have to execute auto-backup.sh to persist the changes to /etc/rc.local.d/local.sh ?

    • Derek Shaw says:

      persisted after reboot – but I had already execute auto-backup.sh, because I suspect it is required, given the in-memory filesystem of esxi.

      Next we test whether the same method of persisting the changes to the firewall for sending the email notifications work…
      that is, make a firewall.tgz file that has content of /etc/vmware/firewall/smtp.xml, and copy it to /bootbank
      nb – smtp.xml has the directives to allow smtp outbound
      – see WLam’s article http://www.virtuallyghetto.com/2011/08/how-to-persist-configuration-changes-in_09.html

      contents of smtp.xml (this client still has simple smtp sending available)

      SMTP

      outbound
      tcp
      dst
      25

      true
      false

      • Derek Shaw says:

        well, rats — the code HTML tags didn’t prevent the xml tags from being stripped from the xml example. google will turn up something if you need it.

  2. danielboone says:

    How did you get around the
    ./ghettoVCB-restore.sh: line 389: whoami: not found
    ERROR: This script needs to be executed by “root”!
    ERROR: This script needs to be executed by “root”!

  3. Peter says:

    I changed the whoami line to

    WHOAMI=$(who | awk ‘{print $1}’)
    if [ ! $WHOAMI == “root” ]; then

  4. Peter says:

    Of course this worked because I was the only one logged in and ran the script from the command line.

  5. Chris says:

    Hey there,

    my crontab/cronjob does’t start… i put the lines into my local.sh file like this

    #!/bin/sh

    # local configuration options

    # Note: modify at your own risk! If you do/use anything in this
    # script that is not part of a stable API (relying on files to be in
    # specific places, specific tools, specific output, etc) there is a
    # possibility you will end up with a broken system after patching or
    # upgrading. Changes are not supported unless under direction of
    # VMware support.

    /bin/kill $(cat /var/run/crond.pid)
    /bin/echo ’30 0 * * * /vmfs/volumes/DataStore1/ghettoVCB/backup.sh’ >> /var/spool/cron/crontabs/root
    /usr/lib/vmware/busybox/bin/busybox crond

    exit 0

    but nothing happend 🙁

    i reades so many about the cron and nothing will really work…

    btw i have the esxi 5.1 from HP

    thx

    Chris

    • Mike Waldron says:

      Your problem looks like it’s twofold. One you need double quotes in the injection line. Two, you are not telling ghettoVCB what to backup. You’ll need to add -a to the end of the command line to backup all VMs.

      Here’s my injection line which works:

      /bin/echo “0 6 * * 0 /vmfs/volumes/datastore1/Tools/ghettoVCB/ghettoVCB.sh -a > /vmfs/volumes/datastore2/VMBackups/Logs/backup.log” >> /var/spool/cron/crontabs/root

      Check to see if your injection worked by using the command:

      cat /var/spool/cron/crontabs/root

      Mine looks like:

      #min hour day mon dow command
      1 1 * * * /sbin/tmpwatch.py
      1 * * * * /sbin/auto-backup.sh
      0 * * * * /usr/lib/vmware/vmksummary/log-heartbeat.py
      */5 * * * * /sbin/hostd-probe
      0 6 * * 0 /vmfs/volumes/datastore1/Tools/ghettoVCB/ghettoVCB.sh -a > /vmfs/volumes/datastore2/VMBackups/Logs/backup.log

  6. Ross Dunham says:

    Greetings.
    I am looking for some advice in debugging my cron job.
    It does not appear to execute at the scheduled time.
    Statement injection to local.sh appears to work properly after reboot.

    I just get nothing in the logs and no backup on the NFS share.
    Here is my cron entry (just in case I did something really dumb).
    I want it to run at 3am every saturday.

    0 3 * * 6 /vmfs/volumes/datastore1/ghettoVCB/ghettoVCB.sh -f /vmfs/volumes/datastore1/ghettoVCB/bu-vms > /vmfs/volumes/datastore1/ghettoVCB/ghettoVCB.log

    Any advice on how to debug this further?

    I am just running the job manually for now.
    Thanks in advance
    Ross

    • Mike Waldron says:

      Does the job run at all, ever? At first glance it looks like your cron job is right. If you do a cat /var/spool/cron/crontabs/root do you see your cron job in the file?

      Remember that Busybox uses GMT not the local time zone, so you’d actually want to schedule it for 11a like so: 0 11 * * 6

  7. Nicki says:

    I changes the whoami line to
    if [ ! $USER == “root” ]; then

    the shell variable $USER should be populated…

    But I still get a warning:
    Insufficient arguments.

    Any idea where that comes from?

  8. Dave says:

    >>Any idea where that comes from?<<

    It's coming from line 246 of version 74, released Nov 27, 2011

    ${VMWARE_CMD} vmsvc/snapshot.remove | grep "snapshotId"

    The syntax changed for vim-cmd.

    lamw is already aware of it. See http://communities.vmware.com/thread/396570

  9. Chad says:

    Hey OP, could you please post a copy of your working script?

  10. Dan says:

    Thanks for the info, I was driving myself nuts trying to edit /etc/rc.local

    I hope lamw has a chance to update the install text to encompass 5.1 soon, I’m sure there are lots of other frustrated newbs like me trying to get this workings.

  11. Chris says:

    Im going to be honest with you. Its been a year since lamw made any changes to this script. It may work for ESXi <= 5.0. But i wouldnt touch it on 5.1. Theres to many unknowns about it.

    • Mike Waldron says:

      Hey Chris, William Lam did update the script a few weeks ago. Because it’s a simple snapshot engine, my workaround was simply for the version check. I used the older version on 5.1 and it still worked 100%… I frequently restore these gvcb backed up VMs and I’ve never had an issue.

  12. kevin says:

    I wouldn’t use the old firewall.tgz method, creating a .vib isn’t too hard and is portable across servers.
    http://www.yellow-bricks.com/2011/11/29/how-to-create-your-own-vib-files/

    Alternatively, there is a new method, but I haven’t tried it yet.
    http://www.virtuallyghetto.com/2012/09/creating-custom-vibs-for-esxi-50-51.html

  13. Parker says:

    I dont know what i’m doing wrong. Is there permissions that you need to set?

    Thanks

    /bin/kill $(cat /var/run/crond.pid)
    /bin/echo “0 6 * * 0 /vmfs/volumes/datastore1/ghettoVCB-master/ghettoVCB.sh -a Win7 > /vmfs/volumes/Raid/ghettoVCB-backup-$(date +\%s).log” >> /var/spool/cron/crontabs/root
    /usr/lib/vmware/busybox/bin/busybox crond
    cat /var/spool/cron/contabs/root
    exit 0
    /etc/rc.local.d # ./local.sh
    ./local.sh: line 13: can’t create /var/spool/cron/crontabs/root: Operation not permitted
    cat: can’t open ‘/var/spool/cron/contabs/root’: No such file or directory

Leave a Reply

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

Web Hosting