<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  
  
  <channel>
    <title>chrisjrob: archive</title>
    <link>https://chrisjrob.com</link>
    <atom:link href="https://chrisjrob.com/tag/archive/feed/index.xml" rel="self" type="application/rss+xml" />
    <description>GNU Linux, Perl and FLOSS</description>
    <language>en-gb</language>
    <pubDate>Fri, 13 Feb 2026 17:22:31 +0000</pubDate>
    <lastBuildDate>Fri, 13 Feb 2026 17:22:31 +0000</lastBuildDate>
    
    <item>
      <title>Howto | Archive to DAT</title>
      <link>https://chrisjrob.com/2010/11/23/archive-to-dat/</link>
      <pubDate>Tue, 23 Nov 2010 16:25:08 +0000</pubDate>
      <author>chrisjrob@gmail.com (Chris Roberts)</author>
      <guid>https://chrisjrob.com/2010/11/23/archive-to-dat</guid>
      <description>
       <![CDATA[
         
           <img src="https://chrisjrob.com/assets/freecom-dat.jpg" align="right" alt="Featured Image">
         
         <p>I am a rank amateur at both tar and mt.  This page constitutes no more than you could discover yourself by reading the manpages for tar and mt, or Googling.</p>

<p>You have been warned!</p>

<h2 id="simple-instructions">Simple instructions</h2>

<!--more-->

<h3 id="rewind">Rewind</h3>

<p><strong>Use the rewind command before backup to ensure that you are overwriting previous backups.</strong></p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># mt -f /dev/st0 rewind
</code></pre></div></div>

<h3 id="backup">Backup</h3>

<p>E.g. directory <code class="language-plaintext highlighter-rouge">/www</code> and <code class="language-plaintext highlighter-rouge">/home</code> with tar command (z - compressed)</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># tar -czf /dev/st0 /www /home
</code></pre></div></div>

<p><strong>Use -v to receive verbose feedback.</strong></p>

<h3 id="backup-with-verify">Backup with Verify</h3>

<p>If you do not compress your backup, then you can verify in the same process:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># tar -cWf /dev/st0 /www /home
</code></pre></div></div>

<h3 id="where">Where</h3>

<p>Find out what block you are at with mt command:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># mt -f /dev/st0 tell
</code></pre></div></div>

<p>This does not appear to work on my version of the software.  In theory the Status option has a line for <code class="language-plaintext highlighter-rouge">block number=</code>, but surprising after completing a backup it seems to still return 0.  If I ever work out why this is, I will update this entry.</p>

<h3 id="list">List</h3>

<p>Display list of files on tape drive:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># tar -tzf /dev/st0
</code></pre></div></div>

<h3 id="restore">Restore</h3>

<p>E.g. <code class="language-plaintext highlighter-rouge">/www</code> directory</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># cd /
# mt -f /dev/st0 rewind
# tar -xzf /dev/st0 www
</code></pre></div></div>

<p>E.g. <code class="language-plaintext highlighter-rouge">/home/test</code> directory</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># cd /
# mt -f /dev/st0 rewind
# tar --checkpoint -xvvzpkf /dev/st0 home/test

--checkpoint : provide occasional checkpoint messages
-x : extract
-v : verbosely
-v : even more verbosly
-z : uncompress
-p : retaining permissions
-k : leaving existing files alone
-f /dev/st0 home/test
</code></pre></div></div>

<h3 id="unload">Unload</h3>

<p>Unload the tape:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># mt -f /dev/st0 offline
</code></pre></div></div>

<h3 id="status">Status</h3>

<p>Display status information about the tape unit:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># mt -f /dev/st0 status
</code></pre></div></div>

<h3 id="erase">Erase</h3>

<p>Erasing the tape may take hours and there is not normally any need to do this; simply rewind the tape before performing backup, or use the mt command to position at the beginning of the tape.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># mt -f /dev/st0 erase
</code></pre></div></div>

<h3 id="moving-about-the-tape">Moving about the tape</h3>

<p>You can go BACKWARD or FORWARD on tape with mt command itself</p>

<h4 id="go-to-end-of-data">Go to end of data</h4>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># mt -f /dev/st0 eod
</code></pre></div></div>

<h4 id="goto-previous-record">Goto previous record</h4>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># mt -f /dev/st0 bsfm 1
</code></pre></div></div>

<h4 id="forward-record">Forward record</h4>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># mt -f /dev/st0 fsf 1
</code></pre></div></div>

<h2 id="restore-1">Restore</h2>

<p>This code has not been checked or tested:</p>

<ul>
  <li>Check status of tape: <code class="language-plaintext highlighter-rouge">mt -f /dev/st0</code> status</li>
  <li>Go to the directory where you want to restore your file(s).</li>
  <li>Go to the right file on the tape with the following commands:
    <ul>
      <li>Check file number and position in file: <code class="language-plaintext highlighter-rouge">mt -f /dev/st0 status</code></li>
      <li>Advance one file: <code class="language-plaintext highlighter-rouge">mt -f /dev/st0 fsf 1</code></li>
      <li>View contents of tar-file: <code class="language-plaintext highlighter-rouge">tar -tvf /dev/st0</code></li>
      <li>Go back one file: <code class="language-plaintext highlighter-rouge">mt -f /dev/st0 bsf 1</code></li>
      <li>
        <p>If you are in the last block of a file and you should be at the beginning of the file, do the following:</p>

        <p><code class="language-plaintext highlighter-rouge">mt -f /dev/st0 bsf 1</code></p>

        <p><code class="language-plaintext highlighter-rouge">mt -f /dev/st0 fsf 1</code></p>
      </li>
      <li>And check with: <code class="language-plaintext highlighter-rouge">mt -f /dev/st0 status</code></li>
    </ul>
  </li>
  <li>Extract your file(s): <code class="language-plaintext highlighter-rouge">tar -xvf /dev/st0 ~files~</code></li>
  <li>Rewind and eject tape: <code class="language-plaintext highlighter-rouge">mt -f /dev/st0 offline</code></li>
</ul>

<h2 id="hardware-compression">Hardware Compression</h2>

<p>It may be possible to switch off and on the hardware compression on the:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># mt -f /dev/st0 compression 0
# mt -f /dev/st0 compression 1
</code></pre></div></div>

<p>Other people report replacing the 0 with “off” and 1 with “on”.</p>

<h2 id="references">References</h2>

<ul>
  <li>man tar</li>
  <li>man mt</li>
  <li><a href="http://www.cyberciti.biz/faq/linux-tape-backup-with-mt-and-tar-command-howto/">Howto: Linux Tape Backup with MT and TAR commands</a></li>
  <li><a href="http://www.cs.inf.ethz.ch/stricker/lab/linux_tape.html">How to use the DAT-tape with Linux</a></li>
  <li><a href="http://www.cyberciti.biz/faq/unix-verify-tape-backup/">Verify tar command tape backup under Linux or UNIX</a></li>
  <li><a href="http://www.cyberciti.biz/faq/tape-drives-naming-convention-under-linux/">Tape drives naming convention under Linux</a></li>
  <li><a href="http://www.cyberciti.biz/faq/backup-home-directories-in-linux/">Backup home directories in Linux</a></li>
  <li><a href="http://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/">Howto: Use tar command through network over ssh session</a></li>
  <li><a href="http://www.cyberciti.biz/faq/rhel-centos-debian-set-tape-blocksize/">Linux Set the Block Size for a SCSI Tape Device</a></li>
</ul>


       ]]>
      </description>
    </item>
    
  </channel> 
</rss>
