<?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>The Piranha Method &#187; bash</title>
	<atom:link href="http://www.piranhamethod.com/tag/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.piranhamethod.com</link>
	<description>Web Development &#38; Graphic Design Firm - Charlotte, Greenville, Charleston</description>
	<lastBuildDate>Wed, 14 Apr 2010 02:18:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>OpenVZ Container Weekly Bash Backup Script: VZDUMP</title>
		<link>http://www.piranhamethod.com/2009/03/openvz-container-weekly-bash-backup-script/</link>
		<comments>http://www.piranhamethod.com/2009/03/openvz-container-weekly-bash-backup-script/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 08:35:12 +0000</pubDate>
		<dc:creator>Matthew Cluver</dc:creator>
				<category><![CDATA[Debian Linux]]></category>
		<category><![CDATA[Development Blog]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[code snippets]]></category>
		<category><![CDATA[container]]></category>
		<category><![CDATA[openvz]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[ve]]></category>
		<category><![CDATA[virtualization]]></category>
		<category><![CDATA[vps]]></category>
		<category><![CDATA[vzdump]]></category>

		<guid isPermaLink="false">http://www.piranhamethod.com/?p=183</guid>
		<description><![CDATA[This is a handy backup script that will once a week perform a vzdump operation on your HN, thus dumping an imaged copy of all of your virtual machines, then uploading them all to the FTP server of your choice using ncftpput.]]></description>
			<content:encoded><![CDATA[<p>This is a handy backup script that will once a week perform a vzdump operation on your HN, thus dumping an imaged copy of all of your virtual machines, then uploading them all to the FTP server of your choice using ncftpput.<br />
<span id="more-183"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;"># Container backup script</span>
&nbsp;
<span style="color: #666666; font-style: italic;">### System Setup ###</span>
<span style="color: #007800;">BACKUP</span>=<span style="color: #000000; font-weight: bold;">/</span>vz<span style="color: #000000; font-weight: bold;">/</span>backup.<span style="color: #007800;">$$</span>
<span style="color: #007800;">NOW</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #ff0000;">&quot;%Y-%m-%d&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">LAST</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</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>d <span style="color: #660033;">-d</span> <span style="color: #ff0000;">'-7 days'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">DAY</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #ff0000;">&quot;%a&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">HOSTNAME</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(hostname)</span>&quot;</span>
<span style="color: #007800;">DUMP</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(which vzdump)</span>&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">### FTP server Setup ###</span>
<span style="color: #007800;">FTPD</span>=<span style="color: #ff0000;">&quot;/backups&quot;</span>
<span style="color: #007800;">FTPU</span>=<span style="color: #ff0000;">&quot;username&quot;</span>
<span style="color: #007800;">FTPP</span>=<span style="color: #ff0000;">&quot;password&quot;</span>
<span style="color: #007800;">FTPS</span>=<span style="color: #ff0000;">&quot;xxx.xxx.xxx.xxx&quot;</span>
<span style="color: #007800;">NCFTP</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(which ncftp)</span>&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">### Other stuff ###</span>
<span style="color: #007800;">EMAILID</span>=<span style="color: #ff0000;">&quot;support@hostname.com&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">### Start Backup for file system ###</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-d</span> <span style="color: #007800;">$BACKUP</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #007800;">$BACKUP</span> <span style="color: #000000; font-weight: bold;">||</span> :
&nbsp;
<span style="color: #007800;">$DUMP</span> <span style="color: #660033;">--exclude-path</span> <span style="color: #ff0000;">'.+/log/.+'</span> <span style="color: #660033;">--exclude-path</span> <span style="color: #ff0000;">'.+/bak/.+'</span> <span style="color: #660033;">--exclude-path</span> <span style="color: #ff0000;">'/tmp/.+'</span> <span style="color: #660033;">--exclude-path</span> <span style="color: #ff0000;">'/var/tmp/.+'</span> <span style="color: #660033;">--exclude-path</span> <span style="color: #ff0000;">'/var/run/.+pid'</span> <span style="color: #660033;">--stop</span> <span style="color: #660033;">--dumpdir</span>=<span style="color: #007800;">$BACKUP</span> <span style="color: #660033;">--compress</span> <span style="color: #660033;">--all</span>
&nbsp;
<span style="color: #666666; font-style: italic;">### Dump backup using FTP ###</span>
<span style="color: #666666; font-style: italic;">#Start FTP backup using ncftp</span>
<span style="color: #007800;">$NCFTP</span> <span style="color: #660033;">-u</span><span style="color: #ff0000;">&quot;<span style="color: #007800;">$FTPU</span>&quot;</span> <span style="color: #660033;">-p</span><span style="color: #ff0000;">&quot;<span style="color: #007800;">$FTPP</span>&quot;</span> <span style="color: #007800;">$FTPS</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">&lt;</span> EOF
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #007800;">$FTPD</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$NOW</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #007800;">$FTPD</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$NOW</span>
lcd <span style="color: #007800;">$BACKUP</span>
mput <span style="color: #000000; font-weight: bold;">*</span>
<span style="color: #c20cb9; font-weight: bold;">rmdir</span> <span style="color: #007800;">$FTPD</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$LAST</span>
quit
EOF
&nbsp;
<span style="color: #666666; font-style: italic;">### Find out if ftp backup failed or not ###</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$?&quot;</span> == <span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #007800;">$BACKUP</span>
<span style="color: #000000; font-weight: bold;">else</span>
<span style="color: #007800;">T</span>=<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>backup.fail
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Date: <span style="color: #007800;">$(date)</span>&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #007800;">$T</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Hostname: <span style="color: #007800;">$(hostname)</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span><span style="color: #007800;">$T</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Backup failed&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span><span style="color: #007800;">$T</span>
mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;BACKUP FAILED&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$EMAILID</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #007800;">$T</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #007800;">$T</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></td></tr></table></div>

</pre>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share this:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://www.piranhamethod.com/feed/" title="RSS"><img src="http://www.piranhamethod.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.piranhamethod.com%2F2009%2F03%2Fopenvz-container-weekly-bash-backup-script%2F&amp;partner=sociable" title="PDF"><img src="http://www.piranhamethod.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.piranhamethod.com%2F2009%2F03%2Fopenvz-container-weekly-bash-backup-script%2F&amp;partner=sociable" title="Print"><img src="http://www.piranhamethod.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://slashdot.org/bookmark.pl?title=OpenVZ%20Container%20Weekly%20Bash%20Backup%20Script%3A%20VZDUMP&amp;url=http%3A%2F%2Fwww.piranhamethod.com%2F2009%2F03%2Fopenvz-container-weekly-bash-backup-script%2F" title="Slashdot"><img src="http://www.piranhamethod.com/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.piranhamethod.com%2F2009%2F03%2Fopenvz-container-weekly-bash-backup-script%2F&amp;t=OpenVZ%20Container%20Weekly%20Bash%20Backup%20Script%3A%20VZDUMP" title="Facebook"><img src="http://www.piranhamethod.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.piranhamethod.com%2F2009%2F03%2Fopenvz-container-weekly-bash-backup-script%2F&amp;title=OpenVZ%20Container%20Weekly%20Bash%20Backup%20Script%3A%20VZDUMP&amp;source=The+Piranha+Method+Web+Development+%26amp%3B+Graphic+Design+Firm+-+Charlotte%2C+Greenville%2C+Charleston&amp;summary=This%20is%20a%20handy%20backup%20script%20that%20will%20once%20a%20week%20perform%20a%20vzdump%20operation%20on%20your%20HN%2C%20thus%20dumping%20an%20imaged%20copy%20of%20all%20of%20your%20virtual%20machines%2C%20then%20uploading%20them%20all%20to%20the%20FTP%20server%20of%20your%20choice%20using%20ncftpput." title="LinkedIn"><img src="http://www.piranhamethod.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=OpenVZ%20Container%20Weekly%20Bash%20Backup%20Script%3A%20VZDUMP%20-%20http%3A%2F%2Fwww.piranhamethod.com%2F2009%2F03%2Fopenvz-container-weekly-bash-backup-script%2F" title="Twitter"><img src="http://www.piranhamethod.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.piranhamethod.com%2F2009%2F03%2Fopenvz-container-weekly-bash-backup-script%2F&amp;title=OpenVZ%20Container%20Weekly%20Bash%20Backup%20Script%3A%20VZDUMP&amp;bodytext=This%20is%20a%20handy%20backup%20script%20that%20will%20once%20a%20week%20perform%20a%20vzdump%20operation%20on%20your%20HN%2C%20thus%20dumping%20an%20imaged%20copy%20of%20all%20of%20your%20virtual%20machines%2C%20then%20uploading%20them%20all%20to%20the%20FTP%20server%20of%20your%20choice%20using%20ncftpput." title="Digg"><img src="http://www.piranhamethod.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.piranhamethod.com%2F2009%2F03%2Fopenvz-container-weekly-bash-backup-script%2F&amp;title=OpenVZ%20Container%20Weekly%20Bash%20Backup%20Script%3A%20VZDUMP&amp;notes=This%20is%20a%20handy%20backup%20script%20that%20will%20once%20a%20week%20perform%20a%20vzdump%20operation%20on%20your%20HN%2C%20thus%20dumping%20an%20imaged%20copy%20of%20all%20of%20your%20virtual%20machines%2C%20then%20uploading%20them%20all%20to%20the%20FTP%20server%20of%20your%20choice%20using%20ncftpput." title="del.icio.us"><img src="http://www.piranhamethod.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.piranhamethod.com%2F2009%2F03%2Fopenvz-container-weekly-bash-backup-script%2F&amp;title=OpenVZ%20Container%20Weekly%20Bash%20Backup%20Script%3A%20VZDUMP&amp;annotation=This%20is%20a%20handy%20backup%20script%20that%20will%20once%20a%20week%20perform%20a%20vzdump%20operation%20on%20your%20HN%2C%20thus%20dumping%20an%20imaged%20copy%20of%20all%20of%20your%20virtual%20machines%2C%20then%20uploading%20them%20all%20to%20the%20FTP%20server%20of%20your%20choice%20using%20ncftpput." title="Google Bookmarks"><img src="http://www.piranhamethod.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.piranhamethod.com%2F2009%2F03%2Fopenvz-container-weekly-bash-backup-script%2F&amp;t=OpenVZ%20Container%20Weekly%20Bash%20Backup%20Script%3A%20VZDUMP" title="MySpace"><img src="http://www.piranhamethod.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.piranhamethod.com%2F2009%2F03%2Fopenvz-container-weekly-bash-backup-script%2F&amp;title=OpenVZ%20Container%20Weekly%20Bash%20Backup%20Script%3A%20VZDUMP" title="StumbleUpon"><img src="http://www.piranhamethod.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.piranhamethod.com%2F2009%2F03%2Fopenvz-container-weekly-bash-backup-script%2F" title="Technorati"><img src="http://www.piranhamethod.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.piranhamethod.com%2F2009%2F03%2Fopenvz-container-weekly-bash-backup-script%2F&amp;t=OpenVZ%20Container%20Weekly%20Bash%20Backup%20Script%3A%20VZDUMP" title="HackerNews"><img src="http://www.piranhamethod.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.piranhamethod.com/2009/03/openvz-container-weekly-bash-backup-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
