<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: VCB &#8211; Backup all running VMs</title>
	<atom:link href="http://www.yellow-bricks.com/2008/01/30/vcb-backup-all-running-vms/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.yellow-bricks.com/2008/01/30/vcb-backup-all-running-vms/</link>
	<description>Building blocks for virtualization...</description>
	<lastBuildDate>Thu, 18 Mar 2010 19:25:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: tdubb</title>
		<link>http://www.yellow-bricks.com/2008/01/30/vcb-backup-all-running-vms/comment-page-1/#comment-3360</link>
		<dc:creator>tdubb</dc:creator>
		<pubDate>Sat, 02 May 2009 18:24:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.yellow-bricks.com/2008/01/30/vcb-backup-all-running-vms/#comment-3360</guid>
		<description>I am getting an error saying 

&quot;2 was expected at this time&quot;</description>
		<content:encoded><![CDATA[<p>I am getting an error saying </p>
<p>&#8220;2 was expected at this time&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff d</title>
		<link>http://www.yellow-bricks.com/2008/01/30/vcb-backup-all-running-vms/comment-page-1/#comment-2448</link>
		<dc:creator>Jeff d</dc:creator>
		<pubDate>Wed, 11 Feb 2009 21:52:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.yellow-bricks.com/2008/01/30/vcb-backup-all-running-vms/#comment-2448</guid>
		<description>I&#039;ve been testing this script and it&#039;s working well but I get a &quot;The system cannot find the specified file&quot; printed to the screen once for every VM that it backed up.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve been testing this script and it&#8217;s working well but I get a &#8220;The system cannot find the specified file&#8221; printed to the screen once for every VM that it backed up.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Duncan Epping</title>
		<link>http://www.yellow-bricks.com/2008/01/30/vcb-backup-all-running-vms/comment-page-1/#comment-385</link>
		<dc:creator>Duncan Epping</dc:creator>
		<pubDate>Tue, 25 Mar 2008 19:21:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.yellow-bricks.com/2008/01/30/vcb-backup-all-running-vms/#comment-385</guid>
		<description>thanks for sharing!</description>
		<content:encoded><![CDATA[<p>thanks for sharing!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin Cheramie</title>
		<link>http://www.yellow-bricks.com/2008/01/30/vcb-backup-all-running-vms/comment-page-1/#comment-383</link>
		<dc:creator>Kevin Cheramie</dc:creator>
		<pubDate>Tue, 25 Mar 2008 18:47:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.yellow-bricks.com/2008/01/30/vcb-backup-all-running-vms/#comment-383</guid>
		<description>Here is a bash script I use to hot backup the VM&#039;s on my ESX servers to NFS storage. This script takes certain things for granted, to an extent.  Some things have to be in place before this script will work properly. I will attempt to list these things here:

1) An account used only for backup administration should be created. I don&#039;t recommend using the root account. A user such as &quot;vmbkupadmin&quot; with an associated password and appropriate permissions on each VM should be created. This information will then be added to the file /etc/vmware/backuptools.conf, for which the following lines must be changed:

VCHOST=ESX-SERVER-HOST-NAME
USERNAME=vmbkupadmin
PASSWORD=SECURE-PASSWORD

Hopefully you can tell where you need to change information to match your environment.
Next, all my NFS shares have the name &quot;datastore-bkup&quot;, so my script looks for that and builds the repository directory off that information.

If you have some basic bash scripting skills, you are probably doing better than me and should be able to bend this to your will.

#!/bin/sh
# Kevin Cheramie 03-13-2008

set -u
set -e

##################
# Trap premature exit conditions
trap badexit 1 2 3 6

badexit ()
{
  printf &quot;Premature exit, caught signal... exiting: `date` \n ---\n&quot; &#124; tee -a /var/log/vmhotbackup.log
  exit 1
}

##################
# Establish a start timestamp, and later, an end timestamp.
#
printf &quot;VM hot backups begin: `date` \n&quot; &#124; tee -a /var/log/vmhotbackup.log

##################
# Construct the datastore name as it may be different from host to host
#
printf &quot;\nDetermining datastore location information...\n&quot;
DATASTORE=`find /vmfs/volumes/ -name datastore*`
HOSTNAME=`hostname`
printf &quot;Datastore info: ${DATASTORE}\n&quot;

##################
# If the datastore does not exist, the script will exit. Go create it, then try again.
#
if [ -z &quot;$DATASTORE&quot; ]
 then
        printf &quot;\n$0: ERROR: Please ensure that a valid NFS datastore exists.\n&quot;
        printf &quot;Exiting...\n&quot;
        exit 1
fi
printf &quot;\nDatastore does exist. Continuing...\n&quot;

##################
# If the datastore exists, but the host does not have it&#039;s own repository folder, we will make one.
#
if [ ! -d ${DATASTORE}/${HOSTNAME} ]
 then
        printf &quot;\n$0: ERROR: Datastore repository does not exist - Creating...\n&quot;
        mkdir ${DATASTORE}/${HOSTNAME}
        printf &quot;Done.\n&quot;
 else
        printf &quot;\nDatastore repository ${DATASTORE}/${HOSTNAME} does exist.\n&quot;
fi

##################
# exit script if /etc/vmware/backuptools.conf does not contain username vmbkupadmin
#
printf &quot;\nVerifying /etc/backuptools.conf configuration...\n&quot;
grep vmbkupadmin /etc/vmware/backuptools.conf &gt; /dev/null 2&gt;&amp;1 &#124;&#124; { printf &quot;$0: ERROR: /etc/backuptools.conf is misconfigured. Repair and try again
.\n&quot;; exit 1; }
printf &quot;/etc/backuptools.conf is configured properly...\n&quot;

##################
# Get a list of all VM&#039;s and feed it into an array
#
printf &quot;\nRetreiving list of valid VM guests...\n&quot;
i=0
for vmguest in `vcbVmName -h $HOSTNAME -s any: &#124; grep name &#124; awk -F: &#039;{print $2}&#039;`
do
  ARRAY[$i]=$vmguest
#  printf &quot;${ARRAY[i]} is in position $i of the array.\n&quot;
  i=`expr $i + 1`
done

##################
# Determine the number of elements in the array
#
VMTOTAL=${#ARRAY[@]}
# echo array&#039;s content
#echo ${ARRAY[@]}
printf &quot;\nTotal elements in the array=$VMTOTAL\n&quot;

##################
# Begin the back up of guest OS&#039;s from the derived list
# the form of the command is as follows:
#       vcbMounter -a name:GUEST_VM_NAME -r /PATH-TO-NFS-DATASTORE/ESX-HOSTNAME/GUEST_VM_NAME
#
# We will work within a loop to walk through the derived list one VM at a time.
# For the record, this will create a hot backup of each VM by causing each to momentarily quiesce,
#   create a recoverable snapshot, export that snapshot and all associated VM configuration files
#   to an NFS repository, and remove the snapshot. Running VM operations are only temporarily
#   interrupted. Users should not notice a difference.
#

x=0
while [ $x -lt &quot;$VMTOTAL&quot; ]
do
##      printf &quot;${ARRAY[x]} is in position $x of the array.\n&quot;
        printf &quot;\nBegin back up of ${ARRAY[x]} at `date`\n&quot;
        /usr/sbin/vcbMounter -a name:${ARRAY[x]} -r ${DATASTORE}/${HOSTNAME}/${ARRAY[x]}
        printf &quot;\nEnd backup of ${ARRAY[x]} at `date`\n&quot;
        x=`expr $x + 1`
done
##################
# End script
printf &quot;\nAll VM guests have been backed up.\n\nEnd timestamp: `date` \n ---\n&quot; &#124; tee -a /var/log/vmhotbackup.log</description>
		<content:encoded><![CDATA[<p>Here is a bash script I use to hot backup the VM&#8217;s on my ESX servers to NFS storage. This script takes certain things for granted, to an extent.  Some things have to be in place before this script will work properly. I will attempt to list these things here:</p>
<p>1) An account used only for backup administration should be created. I don&#8217;t recommend using the root account. A user such as &#8220;vmbkupadmin&#8221; with an associated password and appropriate permissions on each VM should be created. This information will then be added to the file /etc/vmware/backuptools.conf, for which the following lines must be changed:</p>
<p>VCHOST=ESX-SERVER-HOST-NAME<br />
USERNAME=vmbkupadmin<br />
PASSWORD=SECURE-PASSWORD</p>
<p>Hopefully you can tell where you need to change information to match your environment.<br />
Next, all my NFS shares have the name &#8220;datastore-bkup&#8221;, so my script looks for that and builds the repository directory off that information.</p>
<p>If you have some basic bash scripting skills, you are probably doing better than me and should be able to bend this to your will.</p>
<p>#!/bin/sh<br />
# Kevin Cheramie 03-13-2008</p>
<p>set -u<br />
set -e</p>
<p>##################<br />
# Trap premature exit conditions<br />
trap badexit 1 2 3 6</p>
<p>badexit ()<br />
{<br />
  printf &#8220;Premature exit, caught signal&#8230; exiting: `date` \n &#8212;\n&#8221; | tee -a /var/log/vmhotbackup.log<br />
  exit 1<br />
}</p>
<p>##################<br />
# Establish a start timestamp, and later, an end timestamp.<br />
#<br />
printf &#8220;VM hot backups begin: `date` \n&#8221; | tee -a /var/log/vmhotbackup.log</p>
<p>##################<br />
# Construct the datastore name as it may be different from host to host<br />
#<br />
printf &#8220;\nDetermining datastore location information&#8230;\n&#8221;<br />
DATASTORE=`find /vmfs/volumes/ -name datastore*`<br />
HOSTNAME=`hostname`<br />
printf &#8220;Datastore info: ${DATASTORE}\n&#8221;</p>
<p>##################<br />
# If the datastore does not exist, the script will exit. Go create it, then try again.<br />
#<br />
if [ -z "$DATASTORE" ]<br />
 then<br />
        printf &#8220;\n$0: ERROR: Please ensure that a valid NFS datastore exists.\n&#8221;<br />
        printf &#8220;Exiting&#8230;\n&#8221;<br />
        exit 1<br />
fi<br />
printf &#8220;\nDatastore does exist. Continuing&#8230;\n&#8221;</p>
<p>##################<br />
# If the datastore exists, but the host does not have it&#8217;s own repository folder, we will make one.<br />
#<br />
if [ ! -d ${DATASTORE}/${HOSTNAME} ]<br />
 then<br />
        printf &#8220;\n$0: ERROR: Datastore repository does not exist &#8211; Creating&#8230;\n&#8221;<br />
        mkdir ${DATASTORE}/${HOSTNAME}<br />
        printf &#8220;Done.\n&#8221;<br />
 else<br />
        printf &#8220;\nDatastore repository ${DATASTORE}/${HOSTNAME} does exist.\n&#8221;<br />
fi</p>
<p>##################<br />
# exit script if /etc/vmware/backuptools.conf does not contain username vmbkupadmin<br />
#<br />
printf &#8220;\nVerifying /etc/backuptools.conf configuration&#8230;\n&#8221;<br />
grep vmbkupadmin /etc/vmware/backuptools.conf &gt; /dev/null 2&gt;&amp;1 || { printf &#8220;$0: ERROR: /etc/backuptools.conf is misconfigured. Repair and try again<br />
.\n&#8221;; exit 1; }<br />
printf &#8220;/etc/backuptools.conf is configured properly&#8230;\n&#8221;</p>
<p>##################<br />
# Get a list of all VM&#8217;s and feed it into an array<br />
#<br />
printf &#8220;\nRetreiving list of valid VM guests&#8230;\n&#8221;<br />
i=0<br />
for vmguest in `vcbVmName -h $HOSTNAME -s any: | grep name | awk -F: &#8216;{print $2}&#8217;`<br />
do<br />
  ARRAY[$i]=$vmguest<br />
#  printf &#8220;${ARRAY[i]} is in position $i of the array.\n&#8221;<br />
  i=`expr $i + 1`<br />
done</p>
<p>##################<br />
# Determine the number of elements in the array<br />
#<br />
VMTOTAL=${#ARRAY[@]}<br />
# echo array&#8217;s content<br />
#echo ${ARRAY[@]}<br />
printf &#8220;\nTotal elements in the array=$VMTOTAL\n&#8221;</p>
<p>##################<br />
# Begin the back up of guest OS&#8217;s from the derived list<br />
# the form of the command is as follows:<br />
#       vcbMounter -a name:GUEST_VM_NAME -r /PATH-TO-NFS-DATASTORE/ESX-HOSTNAME/GUEST_VM_NAME<br />
#<br />
# We will work within a loop to walk through the derived list one VM at a time.<br />
# For the record, this will create a hot backup of each VM by causing each to momentarily quiesce,<br />
#   create a recoverable snapshot, export that snapshot and all associated VM configuration files<br />
#   to an NFS repository, and remove the snapshot. Running VM operations are only temporarily<br />
#   interrupted. Users should not notice a difference.<br />
#</p>
<p>x=0<br />
while [ $x -lt "$VMTOTAL" ]<br />
do<br />
##      printf &#8220;${ARRAY[x]} is in position $x of the array.\n&#8221;<br />
        printf &#8220;\nBegin back up of ${ARRAY[x]} at `date`\n&#8221;<br />
        /usr/sbin/vcbMounter -a name:${ARRAY[x]} -r ${DATASTORE}/${HOSTNAME}/${ARRAY[x]}<br />
        printf &#8220;\nEnd backup of ${ARRAY[x]} at `date`\n&#8221;<br />
        x=`expr $x + 1`<br />
done<br />
##################<br />
# End script<br />
printf &#8220;\nAll VM guests have been backed up.\n\nEnd timestamp: `date` \n &#8212;\n&#8221; | tee -a /var/log/vmhotbackup.log</p>
]]></content:encoded>
	</item>
</channel>
</rss>
