Content-type: text/html

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  <meta name="Generator" content="wrote by hand">
  <meta name="Author" content="Joey Kelly">
  <title>JKWiki: LinuxTapeBackupScript</title>
  <link type="text/css" href="jkwiki.css" rel="stylesheet"/>
  <script src="jkwiki.js"></script>
  <link rel="shortcut icon" href="jokeshow.jpg" type="image/x-icon">
</head>

<body>

  <div id="page">

    <div id="content">
      <!-- <h1>JKWiki: <small>LinuxTapeBackupScript</small></h1> -->
        <p><a href="?HomePage">HomePage</a> :: <a href="?TechnicalProjects">TechnicalProjects</a> :: LinuxTapeBackupScript</p>
<h1><a id="LinuxTapeBackupScript"></a>Linux Tape Backup Script</h1>
<p><strong>NOTE:</strong> All of the information on this page was written by <a href="http://nolug.org/index.pl?ScottManzella">Scott Manzella</a></p>
<h1><a id="SimpleBackupScriptUsingTar"></a>Simple Backup Script Using tar</h1>
<pre>
 #!/bin/bash
 # Tape Backup Procedure
 #
 /usr/bin/mt -f /dev/st0 load
 /bin/sleep 5
 /usr/bin/mt -f /dev/st0 retension
 /bin/sleep 5
 /bin/tar -cvf /dev/st0 /etc /home /root /srv /bin /usr
 /bin/sleep 5
 /usr/bin/mt -f /dev/st0 offline
 exit
</pre>
<h1><a id="Notes"></a>Notes</h1>
<p>This particular script was specifically designed to run on SuSE. With exception to the mt load option, this script should work on a SuSE installation with either a DDS or Travan drive.</p>
<p>The load option does not work in the SuSE implementation of mt. However, the mt load option does work under Red Hat. This option is useful for some tape drives that are slow to recognize media, especially the DDS (2,3,4) drives. It <q>wakes</q> the tape drive and makes it ready for further tape operations.</p>
<p>A sleep command after each tape operation can prevent the tape from returning a tape not ready response to the next command. The sleep command gives the tape drive a few seconds to catch up and make itself ready for the next command.</p>
<p>The mt retension option is only necessary for Travan drives. DDS tapes do not need to be retensioned. Travan tapes should be retensioned before each use.</p>
<p>The data that is to be backed up is tarred to tape. (This is what tar (tape archive) was originally designed for). the -cvf option is used:</p>
<p>c - create archive</p>
<p>v - verbose mode, lots of pretty files scrolling down the screen</p>
<p>f - specifies the output file which is a tape drive &#8212; in our example (/dev/st0)</p>
<p>Be aware that if your tape drive is a SCSI unit, /dev/st0 works automatically. Some Travan drives are IDE. In the event that an IDE drive is used, SCSI emulation must be employed to allow the mt and tar commands to work properly with the tape drive. Check with your OS documentation for the best way to emulate SCSI on an IDE device.</p>
<p>The mt offline command ejects the tape from the drive. DDS tapes are physically ejected by the drive. Travan tapes are simply made ready to be removed by the user.</p>
<p>One option that can be placed after the mt load command is the mt erase command. This command will quickly erase a tape. Erasing a tape is useful for avoiding a read only error returned by some tapes after they are used with various commercial backup applications.</p>
<p>Also, be aware that in order to use this script on a Red Hat box, it is necessary to provide the correct paths for the mt command. On a Red Hat box, mt is located in /bin/mt, not /usr/bin/mt as it is on a Suse box.</p>

    </div>

    <div id="footer">
      <hr>
      <small><i><b><a href="https://gitlab.com/mmlj4/jkwiki">JKWiki</a></b> is a scraped-together wiki app by Joey Kelly</i></small>
    </div>

  </div>

</body>
</html>
