<?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>wally's blog &#187; backup</title>
	<atom:link href="http://matt.matzi.org.uk/tag/backup/feed/" rel="self" type="application/rss+xml" />
	<link>http://matt.matzi.org.uk</link>
	<description>Delving deep into the mind of me</description>
	<lastBuildDate>Thu, 19 Aug 2010 10:48:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0-beta1</generator>
		<item>
		<title>Reconstructing heavily damaged hard drives</title>
		<link>http://matt.matzi.org.uk/2008/07/03/reconstructing-heavily-damaged-hard-drives/</link>
		<comments>http://matt.matzi.org.uk/2008/07/03/reconstructing-heavily-damaged-hard-drives/#comments</comments>
		<pubDate>Thu, 03 Jul 2008 11:22:09 +0000</pubDate>
		<dc:creator>wally</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Sys Admin]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[forensics]]></category>
		<category><![CDATA[helix]]></category>
		<category><![CDATA[recovery]]></category>

		<guid isPermaLink="false">http://matt.matzi.org.uk/?p=46</guid>
		<description><![CDATA[Recover data even when an NTFS (or other) won&#8217;t mount due to partial hard drive failure. This was born when someone brought me a near dead hard drive (a serious number of read errors, so bad that nothing could mount or fix the filesystem), asking if I could recover any data. Now obviously (as almost [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Recover data even when an NTFS (or other) won&#8217;t mount due to partial hard drive failure.</strong></p>
<p>This was born when someone brought me a near dead hard drive (a serious number of read errors, so bad that nothing could mount or fix the filesystem), asking if I could recover any data.</p>
<p>Now obviously (as almost any geek would know), the answer of course is a very likely yes. There are many ways of recovering data. One such way (which I performed) is using <a href="http://linux.die.net/man/1/foremost">Foremost</a> to find files based on their headers and structures. While this technique works really quite well, it does miss a lot of files, fragment others up, leave bits out and generally not retrieve any metadata (such as filenames etc).</p>
<p>This makes Matt mad.  No filenames == days of renaming files.</p>
<p>So I booted up <a href="http://www.e-fense.com/helix/">Helix</a>, created a quick image of the drive to a 500GB external drive, and tried running <a href="http://www.sleuthkit.org/">Autopsy </a>(the GUI of Sleuthkit).  This is where things got interesting.</p>
<p>I say interesting, because Sleuthkit <em>couldn&#8217;t</em> read the filesystem.  But it <em>could</em> retrieve the inodes, and the metadata along with them.  And it could accordingly retrieve the data content of (some) files.</p>
<p>Observing this, I realized there was a high probability that I could somehow <em>use</em> Sleuthkit&#8217;s command line tools to retrieve the files which were not on bad clusters and recover the filenames from the inode. As it turns out, this wasn&#8217;t such a bad idea!</p>
<p>There are 3 tools which proved useful:</p>
<ul>
<li>ils</li>
<li>ffind</li>
<li>icat</li>
</ul>
<p><em>ils</em> &#8220;lists inode information&#8221; from the image, <em>ffind</em> &#8220;finds the name of the file or directory using the given inode&#8221; and <em>icat</em> &#8220;outputs the content of the file based on it&#8217;s inode number&#8221;. Using these three tools and a bit of bash, we can grab a list of inodes, get the filename from the metadata, create the directory structure beneath it, extract the file content, move on to the next.</p>
<p>So for this task I knocked up the following (really ugly, potentially unsafe) script:</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
</pre></td><td class="code"><pre class="bash"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #000000; font-weight: bold;">for</span> inode <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>inodes<span style="color: #7a0874; font-weight: bold;">&#41;</span> ; <span style="color: #000000; font-weight: bold;">do</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">/</span>KNOPPIX<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">/</span>sleuthkit<span style="color: #000000;">-2.09</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ffind <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>hda1 <span style="color: #007800;">$inode</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> -eq <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;INODE: $inode&quot;</span>
	<span style="color: #007800;">INODEDIR=</span><span style="color: #000000; font-weight: bold;">`/</span>KNOPPIX<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">/</span>sleuthkit<span style="color: #000000;">-2.09</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ffind <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>hda1 <span style="color: #007800;">$inode</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
	<span style="color: #007800;">REALDIR=</span><span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>out<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">dirname</span> <span style="color: #ff0000;">&quot;$INODEDIR&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
	<span style="color: #007800;">FILENAME=</span><span style="color: #ff0000;">&quot;/mnt/out$INODEDIR&quot;</span>
	<span style="color: #c20cb9; font-weight: bold;">mkdir</span> -p <span style="color: #ff0000;">&quot;$REALDIR&quot;</span>
&nbsp;
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;FILENAME: $FILENAME&quot;</span>
	<span style="color: #000000; font-weight: bold;">/</span>KNOPPIX<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">/</span>sleuthkit<span style="color: #000000;">-2.09</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>icat <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>hda1 <span style="color: #007800;">$inode</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #ff0000;">&quot;$FILENAME&quot;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">du</span> <span style="color: #ff0000;">&quot;$FILENAME&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span> == <span style="color: #000000;">1</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: #ff0000;">&quot;$FILENAME&quot;</span>
		<span style="color: #c20cb9; font-weight: bold;">mkdir</span> -p <span style="color: #ff0000;">&quot;$FILENAME&quot;</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></td></tr></table></div>

<p>Really, I do warn you, <strong>take serious care running this</strong>!</p>
<p>It needs a lot of work, but enough is there for it to function.  It reads a file of inode numbers (one per line) and uses <em>ffind</em> to get the filename.  We extract the path, attempt to create it, output the file content and (this is important), take a <em><strong>wild guess</strong></em> at if the inode was a directory. Please note this is wildly inaccurate and needs serious rethinking! Currently we look at the file size, and assume directories alone use 1 byte.</p>
<p>We can populate a file with inode numbers like so:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">ils -a <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>hda1 <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> -F <span style="color: #ff0000;">'|'</span> <span style="color: #ff0000;">'{print $1}'</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>inodes</pre></div></div>

<p>(Users of Helix will need to use the full pathname to <em>ils</em> as in the above script).</p>
<p>At some point (no garuntees when) I&#8217;ll tidy up the script and make it more bullet proof. In the meantime, I hope this saves some data!</p>
<p><strong>Remember</strong>: No matter how much data you have, it&#8217;s always better to have 2 hard drives of half the size, mirrored than it is to have one large expensive drive. They <strong><em>will</em></strong> die unexpectedly! When you next buy a bigger hard drive, consider this: 1x500GB drive will loose you 500GB of data. 2x250GB will 99.9% probability loose you nothing. So if you&#8217;re on a tight budget, buy twice smaller. If you&#8217;ve a lot of money, buy twice big.</p>
<p>Oh, and <em><strong>always</strong></em> make regular backups.  Cheap USB drives are good for this!</p>
]]></content:encoded>
			<wfw:commentRss>http://matt.matzi.org.uk/2008/07/03/reconstructing-heavily-damaged-hard-drives/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Full, recoverable, DVD server backups</title>
		<link>http://matt.matzi.org.uk/2008/06/20/full-recoverable-dvd-server-backups/</link>
		<comments>http://matt.matzi.org.uk/2008/06/20/full-recoverable-dvd-server-backups/#comments</comments>
		<pubDate>Fri, 20 Jun 2008 09:07:36 +0000</pubDate>
		<dc:creator>wally</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Sys Admin]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[mondorescue]]></category>
		<category><![CDATA[restore]]></category>

		<guid isPermaLink="false">http://matt.matzi.org.uk/?p=38</guid>
		<description><![CDATA[If you&#8217;re responsible for one or more Linux servers, (they provide packages for Linux distributions only, but it may be easily ported to other Unixes) you may be interested in the lesser known tool MondoRescue. It&#8217;s essentially nothing more (but it is a lot!) than a front end to several other GPL&#8217;ed tools, including BZip, [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re responsible for one or more Linux servers, (they provide packages for Linux distributions <strong>only</strong>, but it may be easily ported to other Unixes) you may be interested in the lesser known tool <a title="MondoRescue" href="http://www.mondorescue.org/">MondoRescue</a>.</p>
<p>It&#8217;s essentially nothing more (but it is a lot!) than a front end to several other GPL&#8217;ed tools, including BZip, growisofs and busybox.  To cut a long story short, it builds a set of CDs, DVDs, USB sticks with a tiny bootable Linux distribution based on your server&#8217;s kernel, which can restore parts or all of your filesystem from tarballs on the media.  It can also backup to tape drives, NFS mounts or a local filesystem.</p>
<p>It has (imo) a nice, clean ncurses interface; and it&#8217;s quick to use.  On an AMD K6 clocked at 350MHz, with 60MB free memory, it took just under 6 hours to compress 8.5GB of data down to a single DVD (4.7GB).  Doing the backup with an &#8220;average&#8221; compression took far less time (around an hour), but would have eaten up several DVDs.</p>
<p>You&#8217;re presented with a wide variety of options when you boot up the produced rescue media.  You can &#8220;nuke&#8221; the system and start from scratch, or just restore the parts you want.  It can handle new disk geometry, and because the entire rescue system is burnt onto the media, (assuming you used CDs, DVDs or USB storage), it&#8217;ll work even if the target machine is clean.</p>
]]></content:encoded>
			<wfw:commentRss>http://matt.matzi.org.uk/2008/06/20/full-recoverable-dvd-server-backups/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
