<?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 Troll-Range &#187; backup</title>
	<atom:link href="http://blog.trollgod.org.uk/tag/backup/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.trollgod.org.uk</link>
	<description>Ghworg&#039;s wibblings and geek projects.</description>
	<lastBuildDate>Sat, 12 Nov 2011 10:10:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>Poor mans offsite backup</title>
		<link>http://blog.trollgod.org.uk/2009/05/poor-mans-offsite-backup/</link>
		<comments>http://blog.trollgod.org.uk/2009/05/poor-mans-offsite-backup/#comments</comments>
		<pubDate>Sat, 02 May 2009 07:00:34 +0000</pubDate>
		<dc:creator>Ghworg</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[gmail]]></category>

		<guid isPermaLink="false">http://blog.trollgod.org.uk/?p=192</guid>
		<description><![CDATA[<p>Before I got some proper offsite backup space* I used to make tarballs of files and dump them in my gmail. Not the most elegant solution but it worked and is free (I know about gmailfs, but I could never get it to work reliably).</p> <p>This is the script I used to send the <span style="color:#777"> . . . &#8594; Read More: <a href="http://blog.trollgod.org.uk/2009/05/poor-mans-offsite-backup/">Poor mans offsite backup</a></span>]]></description>
			<content:encoded><![CDATA[<p>Before I got some proper offsite backup space* I used to make tarballs of files and dump them in my gmail.  Not the most elegant solution but it worked and is free (I know about gmailfs, but I could never get it to work reliably).</p>
<p>This is the script I used to send the files:</p>
<div class="dean_ch" style="white-space: nowrap;">
<span class="co1">#!/usr/bin/env python</span><br />
<span class="kw1">import</span> <span class="kw3">getpass</span><br />
<span class="kw1">import</span> <span class="kw3">optparse</span><br />
<span class="kw1">import</span> <span class="kw3">smtplib</span><br />
<span class="kw1">import</span> <span class="kw3">sys</span></p>
<p><span class="kw1">from</span> <span class="kw3">email</span> <span class="kw1">import</span> Encoders<br />
<span class="kw1">from</span> <span class="kw3">email</span>.<span class="me1">MIMEBase</span> <span class="kw1">import</span> MIMEBase<br />
<span class="kw1">from</span> <span class="kw3">email</span>.<span class="me1">MIMEMultipart</span> <span class="kw1">import</span> MIMEMultipart</p>
<p>
opts = <span class="kw3">optparse</span>.<span class="me1">OptionParser</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
opts.<span class="me1">add_option</span><span class="br0">&#40;</span><span class="st0">&#8216;-u&#8217;</span>, <span class="st0">&#8216;&#8211;username&#8217;</span><span class="br0">&#41;</span><br />
opts.<span class="me1">add_option</span><span class="br0">&#40;</span><span class="st0">&#8216;-p&#8217;</span>, <span class="st0">&#8216;&#8211;password&#8217;</span><span class="br0">&#41;</span><br />
<span class="br0">&#40;</span>options, args<span class="br0">&#41;</span> = opts.<span class="me1">parse_args</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="kw1">if</span> <span class="kw2">len</span><span class="br0">&#40;</span>args<span class="br0">&#41;</span> &lt; <span class="nu0">1</span>:<br />
&nbsp; &nbsp; <span class="kw1">print</span> <span class="st0">&quot;Usage: send_file_to_gmail.py [-u user] [-p pass] filename&quot;</span><br />
&nbsp; &nbsp; <span class="kw3">sys</span>.<span class="me1">exit</span><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span></p>
<p><span class="kw1">if</span> options.<span class="me1">username</span> == <span class="kw2">None</span>:<br />
&nbsp; &nbsp; options.<span class="me1">username</span> = <span class="kw2">raw_input</span><span class="br0">&#40;</span><span class="st0">&quot;Username: &quot;</span><span class="br0">&#41;</span><br />
<span class="kw1">if</span> options.<span class="me1">password</span> == <span class="kw2">None</span>:<br />
&nbsp; &nbsp; options.<span class="me1">password</span> = <span class="kw3">getpass</span>.<span class="kw3">getpass</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="kw1">if</span> options.<span class="me1">username</span><span class="br0">&#91;</span><span class="kw2">len</span><span class="br0">&#40;</span>options.<span class="me1">username</span><span class="br0">&#41;</span><span class="nu0">-10</span>:<span class="br0">&#93;</span> != <span class="st0">&quot;@gmail.com&quot;</span>:<br />
&nbsp; &nbsp; options.<span class="me1">username</span> += <span class="st0">&quot;@gmail.com&quot;</span></p>
<p>
msg = MIMEMultipart<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
msg<span class="br0">&#91;</span><span class="st0">&#8216;Subject&#8217;</span><span class="br0">&#93;</span> = <span class="st0">&quot;Backup of %s&quot;</span> % args<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><br />
msg<span class="br0">&#91;</span><span class="st0">&#8216;From&#8217;</span><span class="br0">&#93;</span> = options.<span class="me1">username</span><br />
msg<span class="br0">&#91;</span><span class="st0">&#8216;To&#8217;</span><span class="br0">&#93;</span> = options.<span class="me1">username</span></p>
<p>msg.<span class="me1">preamble</span> = <span class="st0">&quot;Backup of %s&quot;</span> % args<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><br />
msg.<span class="me1">epilogue</span> = <span class="st0">&quot; &quot;</span></p>
<p>fp = <span class="kw2">open</span><span class="br0">&#40;</span>args<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span>, <span class="st0">&quot;rb&quot;</span><span class="br0">&#41;</span><br />
atfile = MIMEBase<span class="br0">&#40;</span><span class="st0">&quot;application&quot;</span>, <span class="st0">&quot;octet-stream&quot;</span><span class="br0">&#41;</span><br />
atfile.<span class="me1">set_payload</span><span class="br0">&#40;</span>fp.<span class="me1">read</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
fp.<span class="me1">close</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
Encoders.<span class="me1">encode_base64</span><span class="br0">&#40;</span>atfile<span class="br0">&#41;</span><br />
atfile.<span class="me1">add_header</span><span class="br0">&#40;</span><span class="st0">&quot;Content-Disposition&quot;</span>, <span class="st0">&quot;attachment&quot;</span>, filename=args<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="br0">&#41;</span><br />
msg.<span class="me1">attach</span><span class="br0">&#40;</span>atfile<span class="br0">&#41;</span></p>
<p>s = <span class="kw3">smtplib</span>.<span class="me1">SMTP</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="co1">#s.connect(&quot;localhost&quot;, &quot;8025&quot;)</span><br />
s.<span class="me1">connect</span><span class="br0">&#40;</span><span class="st0">&quot;smtp.gmail.com&quot;</span><span class="br0">&#41;</span><br />
s.<span class="me1">ehlo</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
s.<span class="me1">starttls</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
s.<span class="me1">ehlo</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
s.<span class="me1">login</span><span class="br0">&#40;</span>options.<span class="me1">username</span>, options.<span class="me1">password</span><span class="br0">&#41;</span><br />
<span class="kw1">print</span> <span class="st0">&quot;Sending %s&quot;</span> % args<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><br />
s.<span class="me1">sendmail</span><span class="br0">&#40;</span>options.<span class="me1">username</span>, options.<span class="me1">username</span>, msg.<span class="me1">as_string</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
s.<span class="me1">close</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp;</div>
<p>The above code is made available under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT</a> license.</p>
<p>* While I am writing this the Dreamhost backup space I use has been down for about two weeks (it came back briefly a couple of days ago but is back down again now).  I can&#8217;t complain too much as it is a free extra they throw in with the hosting package but I may have to restart my gmail sending if this keeps up.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.trollgod.org.uk/2009/05/poor-mans-offsite-backup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Offsite backup Catch-22</title>
		<link>http://blog.trollgod.org.uk/2009/02/offsite-backup-catch-22/</link>
		<comments>http://blog.trollgod.org.uk/2009/02/offsite-backup-catch-22/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 17:10:02 +0000</pubDate>
		<dc:creator>Ghworg</dc:creator>
				<category><![CDATA[Admin]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[backup]]></category>

		<guid isPermaLink="false">http://blog.trollgod.org.uk/?p=91</guid>
		<description><![CDATA[<p>Over the past couple of days I&#8217;ve been setting up a secure offsite backup for my home machines. Dreamhost started offering 50GB of space for backups for free to their customers, this is vastly superior to the &#8220;send an archive to gmail every now and then&#8221; method I was using before.</p> <p>I decided to <span style="color:#777"> . . . &#8594; Read More: <a href="http://blog.trollgod.org.uk/2009/02/offsite-backup-catch-22/">Offsite backup Catch-22</a></span>]]></description>
			<content:encoded><![CDATA[<p>Over the past couple of days I&#8217;ve been setting up a secure offsite backup for my home machines.  <a href="http://www.dreamhost.com/">Dreamhost</a> started offering 50GB of space for backups for free to their customers, this is vastly superior to the &#8220;send an archive to gmail every now and then&#8221; method I was using before.</p>
<p>I decided to use <a href="http://duplicity.nongnu.org/">duplicity</a> as it will use scp as the transfer (among manu others), encrypts all the data and automatically does incremental backups transferring only the changed files.  Newer versions even support gmail and amazon s3 as backends, which is really cool but not something I need.</p>
<p>I had one problem setting it up, which was the obscure and unhelpful error reporting.</p>
<pre>
Traceback (most recent call last):
  File "/usr/bin/duplicity", line 463, in <module>
    with_tempdir(main)
  File "/usr/bin/duplicity", line 458, in with_tempdir
    fn()
  File "/usr/bin/duplicity", line 451, in main
    incremental_backup(sig_chain)
  File "/usr/bin/duplicity", line 186, in incremental_backup
    bytes_written = write_multivol("inc", tarblock_iter, globals.backend)
  File "/usr/bin/duplicity", line 87, in write_multivol
    globals.gpg_profile,globals.volsize)
  File "/usr/lib/python2.5/site-packages/duplicity/gpg.py", line 217, in GPGWriteFile
    file.write(data)
  File "/usr/lib/python2.5/site-packages/duplicity/gpg.py", line 125, in write
    return self.gpg_input.write(buf)
IOError: [Errno 32] Broken pipe
close failed: [Errno 32] Broken pipe
</pre>
<p>That is not a useful error message (and I&#8217;ve programmed in python), the actual error turned out to be a typo in the GPG key id I had entered.  Once I&#8217;d worked that out everything went fine.</p>
<p>The real problem is the catch-22 between security and recoverability.  In order for the data to be secure it needs to be encrypted, for that you need either a key or a password (or both for an encrypted key).  Therefore in order to restore the data you need a copy of that key/password, but the situations in which you are going to be restoring from the offsite backup are ones in which <strong>all</strong> your data and local backups have gone poof.  In which case the key will have gone poof too.</p>
<p>Okay, if you used <strong>just</strong> a password and memorized it then you&#8217;d be fine.  But a password you can memorize is probably too weak to be secure, certainly for me it is with my terrible memory.</p>
<p>So, in order to make the data recoverable the key used for encryption needs to be backed up offsite too, but then your security goes out the window.  So the key itself needs to be encrypted before sending it offsite, and there we have the catch-22.</p>
<p>Data needs to be encrypted to be secure, but we need to save the key to make the data recoverable, which makes the data insecure.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.trollgod.org.uk/2009/02/offsite-backup-catch-22/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

