<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Look alive. Here comes a buzzard. &#187; ESXi</title>
	<atom:link href="http://blog.glenc.net/category/esxi/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.glenc.net</link>
	<description>Treading water in a sea of man-made confusion.</description>
	<lastBuildDate>Wed, 01 Sep 2010 02:34:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Automated backups for VMWare ESXi</title>
		<link>http://blog.glenc.net/2008/12/27/automated-backups-for-vmware-esxi/</link>
		<comments>http://blog.glenc.net/2008/12/27/automated-backups-for-vmware-esxi/#comments</comments>
		<pubDate>Sun, 28 Dec 2008 02:58:00 +0000</pubDate>
		<dc:creator>glenc</dc:creator>
				<category><![CDATA[ESXi]]></category>
		<category><![CDATA[VMWare]]></category>

		<guid isPermaLink="false">http://blog.glenc.net/?p=112</guid>
		<description><![CDATA[Setting up automated backups for ESXi can be a little tricky.  After quite a bit of searching I finally came up with these steps that worked for me.  I don&#8217;t take credit for any of these.  I&#8217;m just providing you with the steps that I followed and the posts that helped me.
DISCLAIMER: [...]]]></description>
			<content:encoded><![CDATA[<p>Setting up automated backups for ESXi can be a little tricky.  After quite a bit of searching I finally came up with these steps that worked for me.  I don&#8217;t take credit for any of these.  I&#8217;m just providing you with the steps that I followed and the posts that helped me.</p>
<p><strong><span style="color: #ff0000;">DISCLAIMER: There are some unsupported steps here.  Proceed at your own risk!</span></strong></p>
<p><strong>Step 1:  Enable ssh access on your ESXi host.</strong> To do that, follow these steps (originally from <a href="http://www.vm-help.com/esx/esx3i/ESXi_enable_SSH.php">this post</a>).</p>
<p><em>NOTE: You actually don&#8217;t have to enable ssh for this, I just find it convenient to have remote access to the host machine.  If you don&#8217;t want to enable ssh, perform steps 1-3 below, then skip on to section 2.  When you reach section 3, rather than using ssh, you&#8217;ll just execute the commands directly on the host machine at the console.</em></p>
<ol>
<li>From the console on your host (actually on the host machine &#8211; not using the Remote Client), press ALT-F1</li>
<li>Type in the text &#8220;unsupported&#8221; and press ENTER.  Note: the text will not appear as you type.</li>
<li>Enter the root password</li>
<li>Enter the command
<pre name="code" class="bash">vi /etc/inetd.conf</pre>
</li>
<li>Find the line starting with &#8220;#ssh&#8221;.  You can search by pressing / and then typing ssh and pressing Enter.</li>
<li>Once you&#8217;ve found that line, place the cursor on the # and press x.  This should remove the # character.</li>
<li>Now type
<pre name="code" class="bash">:wq!</pre>
<p> and press ENTER to save your changes.</li>
<li>Next you must restart the inetd process.  To do that, you first need the process id.  At the console, enter
<pre name="code" class="bash">ps | grep inetd</pre>
<p>You should get something that looks like this:</p>
<pre name="code" class="bash">1273 1273 busybox      inetd</pre>
<p>In this case, 1273 is the process ID.  To kill the process enter kill -HUP &lt;process id&gt;.  So in this case, you would enter the following command:</p>
<pre name="code" class="bash">kill -HUP 1273</pre>
</li>
<li>SSH is now enabled on your ESXi host machine.  To test this you&#8217;ll need an ssh client.  I&#8217;m using a mac so I can open terminal and enter the following command:
<pre name="code" class="bash">ssh root@&lt;myhost&gt;</pre>
<p>If you&#8217;re using windows you may need something like <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/">PuTTY</a> or <a href="http://www.cygwin.com/">Cygwin</a>.</li>
</ol>
<p><strong>Step 2: Configure your backup datasource</strong></p>
<p>Next you need to figure out where your backups will be stored.  It can be on the ESXi host if you like, but really it should be on a SAN or NAS or something like that.  I&#8217;m using a <a href="http://www.netgear.com/Products/Storage/ReadyNASNVPlus.aspx">Netgear ReadyNAS NV+</a> and it works great.</p>
<ol>
<li>Create a share where your backups will be stored and call it something like &#8220;backups&#8221;.  Make sure that anyone can read/write to this share.</li>
<li>Open the VMWare Infrastructure Client and connect to your host machine as root.</li>
<li>Go to the <strong>Configuration</strong> tab for the host and click <strong>Storage</strong>.</li>
<li>Click <strong>Add Storage&#8230;</strong> and create a new datastore pointing to the share you created in step 1.  Call this datastore something descriptive&#8230;  like &#8220;backups&#8221; <img src='http://blog.glenc.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ol>
<p><strong>Step 3: Set up your backup script.</strong></p>
<p>I found <a href="http://communities.vmware.com/docs/DOC-8760">this great backup script</a>.  It lets you specify the VMs you want to backup in a separate text file which makes it really easy to add new VMs to the rotation.  It also lets you keep a rotating number of VMs if you don&#8217;t want to over-write each backup daily.</p>
<ol>
<li><a href="http://communities.vmware.com/docs/DOC-8760">Download the backup script</a>.</li>
<li>Copy it to the same backup share you created in the last section.  You can create a directory called _scripts to keep it separate from the actual backups.</li>
<li>Open the script and customize the variables at the top.  In my case, all I had to modify was the <strong>VM_BACKUP_VOLUME</strong> variable.  If you named your datastore &#8220;backups&#8221; you can edit this line to look like this:
<pre name="code" class="bash">VM_BACKUP_VOLUME=/vmfs/volumes/backups</pre>
<p> </li>
<li>Create a new text file in the same directory as the backup script called VMs.txt.  In this file enter the name of each VM you want to back up.  Each VM name should be on a new line.  Your file should look something like this:
<pre name="code" class="bash">VM1
VM2
A_THIRD_VM</pre>
</li>
<li>Connect to your host using ssh i.e. <strong>ssh root@&lt;myhost&gt;</strong></li>
<li>Enter this command:
<pre name="code" class="bash">vi /var/spool/cron/crontabs/root</pre>
</li>
<li>Move the cursor to the very end of the file.  Press <strong>a</strong>.  This will enter edit mode.</li>
<li>Press Enter to create a new line and then add the following text:
<pre name="code" class="bash">02 02 * * *  sh /vmfs/volumes/backups/_scripts/ghettoVCB.sh /vmfs/volumes/backups/_scripts/VMs.txt</pre>
<p>This will run the backup script at 2:02 AM every day.  You can change the frequency or time of day if you like.  This <a href="http://www.adminschoice.com/docs/crontab.htm">crontab reference</a> is helpful.</li>
<li>At this point your entire file should look something like this:
<pre name="code" class="bash"> #syntax : minute hour day month dayofweek command
01 01 * * * /sbin/tmpwatch.sh
01 * * * * /sbin/auto-backup.sh #first minute of every hour (run every hour)
00,10,20,30,40,50 * * * * /sbin/decodeSel.sh #Every 10 minutes, translate the latest IPMI SEL data
02 02 * * *  sh /vmfs/volumes/backups/_scripts/ghettoVCB.sh /vmfs/volumes/backups/_scripts/VMs.txt
</pre>
<p>If you are satisfied, press Escape.</li>
<li>Type the following command to save the file and exit:<code>:wq!</code></li>
<li>The backups are now scheduled</li>
</ol>
<p>At this point, you now have backups scheduled to run every day at 2:02 AM.  You can change which VMs are backed-up by editing the VMs.txt file you created.  You could even set up multiple cron jobs with different backup frequencies, and different VMs.txt files to back up different VMs at different times.</p>
<p>Before finishing however, you might want to do a test run.  If you are still connected to the host machine using ssh, enter the following command:</p>
<pre name="code" class="bash">sh /vmfs/volumes/backups/_scripts/ghettoVCB.sh /vmfs/volumes/backups/_scripts/VMs.txt</pre>
<p><strong>IMPORTANT: This will take a while if you have large VMs.  You may want to edit VMs.txt to target a single small VM as a test run.  If it works for that, it should work for the rest.</strong></p>
<p>One last thing.  Unfortunately, the crontabs/root file isn&#8217;t saved after a reboot.  In order to avoid adding the scheduled job after each reboot you may have to follow one of the <a href="http://communities.vmware.com/message/1111591#1111591">techniques described here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.glenc.net/2008/12/27/automated-backups-for-vmware-esxi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
