<?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>Chris Schuld&#039;s Blog &#187; Backup</title>
	<atom:link href="http://chrisschuld.com/tag/backup/feed/" rel="self" type="application/rss+xml" />
	<link>http://chrisschuld.com</link>
	<description>personal musings on the composition of software</description>
	<lastBuildDate>Mon, 30 Aug 2010 03:48:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Backup an OpenVZ VPS</title>
		<link>http://chrisschuld.com/2009/02/backup-an-openvz-vps/</link>
		<comments>http://chrisschuld.com/2009/02/backup-an-openvz-vps/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 05:21:26 +0000</pubDate>
		<dc:creator>Chris Schuld</dc:creator>
				<category><![CDATA[OpenVZ]]></category>
		<category><![CDATA[Backup]]></category>

		<guid isPermaLink="false">http://chrisschuld.com/?p=195</guid>
		<description><![CDATA[There are a lot of ways to backup an OpenVPS without powering them down. I have two critical VPS systems both operating phone/PBX apps (asterisk) which I need to backup and I cannot get them to backup correctly while powered up (driving me nuts). So weekly (early on Sunday mornings) I backup them up by [...]]]></description>
			<content:encoded><![CDATA[<p>There are a lot of ways to backup an OpenVPS without powering them down.  I have two critical VPS systems both operating phone/PBX apps (asterisk) which I need to backup and I cannot get them to backup correctly while powered up (<em>driving me nuts</em>).  So weekly (early on Sunday mornings) I backup them up by quickly powering them off; backing them up and powering them back up.</p>
<p><em>Side Note: Yes, yes, begin the hate mail: I power down the boxes; which creates all of the 65sec of down time.  If anyone is calling my office at 2AM on Sunday morning and can&#8217;t leave a message please email me and I&#8217;ll adjust our backup schedule!<br />
</em></p>
<p>The script also pushes the backup images to a mount at /nfs/backup <em>(a backup NAS system we have in place)</em></p>
<p>Here is how I do it:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #c20cb9; font-weight: bold;">mount</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-q</span> <span style="color: #ff0000;">' nfs '</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">df</span> <span style="color: #660033;">-T</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-w</span> nfs <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-w</span> <span style="color: #ff0000;">&quot;\/nas\/backup&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-wv</span> <span style="color: #ff0000;">&quot;100%&quot;</span>;<span style="color: #000000; font-weight: bold;">then</span>
&nbsp;
        <span style="color: #666666; font-style: italic;"># date in YYYYMMDD format</span>
        <span style="color: #007800;">today</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>Y<span style="color: #000000; font-weight: bold;">%</span>m<span style="color: #000000; font-weight: bold;">%</span>0e<span style="color: #000000; font-weight: bold;">`</span>;
&nbsp;
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;Stopping VZ 105&quot;</span>
        <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>vzctl stop <span style="color: #000000;">105</span>
&nbsp;
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;Dumping VZ 105&quot;</span>
        <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>vzdump <span style="color: #660033;">--suspend</span> <span style="color: #000000;">105</span>
&nbsp;
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;Starting VZ 105&quot;</span>
        <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>vzctl start <span style="color: #000000;">105</span>
&nbsp;
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;Compressing Output&quot;</span>
        <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">gzip</span> <span style="color: #660033;">-9</span> <span style="color: #000000; font-weight: bold;">/</span>vz<span style="color: #000000; font-weight: bold;">/</span>dump<span style="color: #000000; font-weight: bold;">/</span>vzdump-105.tar
&nbsp;
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;Backing up - moving file to NAS&quot;</span>
        <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000; font-weight: bold;">/</span>vz<span style="color: #000000; font-weight: bold;">/</span>dump<span style="color: #000000; font-weight: bold;">/</span>vzdump-105.tar.gz <span style="color: #000000; font-weight: bold;">/</span>nas<span style="color: #000000; font-weight: bold;">/</span>backup<span style="color: #000000; font-weight: bold;">/</span>__hostname__here__<span style="color: #000000; font-weight: bold;">/</span>vzdump-<span style="color: #000000;">105</span>-<span style="color: #007800;">$today</span>.tar.gz
&nbsp;
<span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> Error: the NFS <span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">for</span> the backup NAS does not appear to be correct
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://chrisschuld.com/2009/02/backup-an-openvz-vps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
