<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>backups — th.oughts</title>
    <link>https://th.oughts.org/tag:backups</link>
    <description>Living the fake American dream, 3 years at a time</description>
    <pubDate>Sat, 14 Nov 2026 00:12:11 +0000</pubDate>
    <image>
      <url>https://i.snap.as/ixKmaGoG.jpg</url>
      <title>backups — th.oughts</title>
      <link>https://th.oughts.org/tag:backups</link>
    </image>
    <item>
      <title>Getting into tape backups (Part 2)</title>
      <link>https://th.oughts.org/getting-into-tape-backups-part-2?pk_campaign=rss-feed</link>
      <description>In Part 1, we had a quick introduction to tapes and tape drives and why you would choose one for your backups. In this part, we talk abou...</description>
      <content:encoded><![CDATA[<p>In <a href="https://th.oughts.org/getting-into-tape-backups-part-1">Part 1</a>, we had a quick introduction to tapes and tape drives and why you would choose one for your backups. In this part, we talk about actually using tapes to create a backup strategy using simple scripting.</p>

<p>Of course,  there are plenty of readily available tools that might suit your needs. Writing your own does have a few advantages though: first, it keeps it simple, highly customized and second, when things go wrong, you would probably have a better idea of why the damn thing isn&#39;t working!</p>

<h2 id="a-look-at-tape-s-workings">A look at tape&#39;s workings</h2>

<p>If this is your first time dealing with tapes(as it was for me), there&#39;s a few prerequisites.</p>

<h3 id="tools">Tools</h3>

<p>Tape operations are carried out via the <em>mt</em> tool. Data is written with <em>tar</em>.
Both of these are probably already installed on your system.</p>

<h3 id="writing-data-to-tapes">Writing data to tapes</h3>

<p>Do you remember the good old days of cassette players ? Tapes are similar. A magnetic head reads and writes data from a magnetic ribbon spooled in an enclosure. With that in mind, there are a few operations that you would do frequently:</p>
<ol><li><p><em>rewind</em>: rewinds(of course!) the tape and points the tape head to the beginning of the magnetic ribbon.
Example command: <em>mt -f /dev/nst0 rewind</em></p></li>

<li><p><em>forward</em>:  Move forward count files. Every time data is written, a marker is set at the end. Let&#39;s say, you write some data to the beginning of the tape: <em>tar cvf /dev/nst0 backupdir</em>
Rewind the tape as above. Now, you want to move forward one marker: <em>mt -f /dev/nst0 fsf 1</em></p></li>

<li><p><em>erase</em>: That&#39;s a really slow process and could take hours (if not days) for larger tapes. However, you can also do a short erase: <em>mt -f /dev/nst0 erase 0</em>.</p></li></ol>

<h3 id="tar-and-incremental-backups">Tar and incremental backups</h3>

<p><em>tar</em> has a handy feature that lets you do incremental backups and the workings are really simple.
Let&#39;s look at an example:</p>
<ol><li><p><em>tar -C /home —listed-incremental=diff.snar -clpMvf /dev/nst0 data</em>
This is what we call a <strong>Level 0</strong> backup. <em>diff.snar</em> is special – it contains a log of all the files that were added to the archive.</p></li>

<li><p>Next, lets&#39;s say you add <em>file.txt</em> to folder <em>data</em> and run the above command again. The only file that would be added to the archive is <em>file.txt</em>. Moreover, <em>diff.snar</em> would also be overwritten with the only one entry that was just added to the archive. This would be a <strong>Level 1</strong> archive.</p></li></ol>

<p>Obviously, if you would want to have a record of all the backups, you wouldn&#39;t want to overwrite <em>diff.snar</em> but have rather something like this:</p>
<ul><li><em>diff0.snar: level0 backup</em></li>
<li><em>diff1.snar: level1 backup</em>
and so on...</li></ul>

<h3 id="backup-strategy">Backup Strategy</h3>

<p>With all this quick preliminary information, we can try a incremental backup strategy as follows:</p>
<ol><li>Maintain two sets of full backup tapes and two sets of incremental backup tapes.</li>
<li>Create a full backup the start of every cycle: could be a month, bimonthly, quarterly or whatever you prefer.</li>
<li>Until the beginning of next cycle, perform incremental backups.</li>
<li>At any point of time, you should always have a backup set that has a full backup of the last cycle as well as incremental backup tape(s) of the last cycle.</li></ol>

<p><a href="https://bitbucket.org/bdas/tape-backup/src/master/tapeutility.sh">Tape utility script</a> illustrates the idea. To perform a full backup, you would run something like:</p>

<p><em>tapeutility.sh -d /dev/nst0 -F -p /etc/tapeutility/folders.txt</em> where “-F” does a full backup of folders listed in “folders.txt”.</p>

<p>For the next run, to create an incremental backup, you would run:
<em>tapeutility.sh -d /dev/nst0 -I -p /etc/tapeutility/folders.txt</em> where “-I” does an incremental backup.</p>

<p>Please take a look at the script for how the metadata file is determined for incremental backup and other features available for basic tape maintenance.</p>

<h3 id="wrap-up">Wrap-up</h3>

<p>I presented a simple way to use tapes for backups. Using a combination of full and incremental backups, and maintaining two sets of tapes, we have reliable backup of data that you could combine with a RAID style setup for long term reliable data storage.</p>

<p><a href="https://th.oughts.org/tag:backups" class="hashtag"><span>#</span><span class="p-category">backups</span></a> <a href="https://th.oughts.org/tag:bash" class="hashtag"><span>#</span><span class="p-category">bash</span></a> <a href="https://th.oughts.org/tag:diy" class="hashtag"><span>#</span><span class="p-category">diy</span></a></p>

<p><a href="https://remark.as/p/th.oughts.org/getting-into-tape-backups-part-2">Discuss...</a></p>
]]></content:encoded>
      <guid>https://th.oughts.org/getting-into-tape-backups-part-2</guid>
      <pubDate>Wed, 10 Aug 2022 04:37:56 +0000</pubDate>
    </item>
  </channel>
</rss>