Next Previous Contents

7. Backing up and restoring data

This section describes some simple uses of tar and mt. Other examples can be found in the ftape-manual of the ftape-doc package. The ftape-tools contains some simple automated DejaGnu

Package for writing automated tests.
test-suites. See section Getting ftape for informations about where to download those additional packages from.

7.1 Writing an archive to a tape

You can use `tar', `dd', `cpio', and `afio'. You will need to use `mt' to get the full potential of your tapes and the ftape driver. For a start I'd recommend using `tar', as it can archive lots of directories and let you pick out separate files from an archive. cpio creates smaller archives and is more generally more flexible than tar, but is missing some features like volume labels. `afio' creates backups where each file is compressed individually and then concatenated. This will allow you to access the files ``after'' the point of the error. If you use gzipped tar files, all data after the point of the error is lost! (to me, this is a pretty good reason for NOT using compression on backups). The choice of which is most appropriate depends on the situation and the features and malfeatures of each of the packages. I recommend taking a look at each package at reviewing the options that each provides. It's possible that this HOWTO may provide more detail on this subject at some point in the future.

There are more links pointing to backup software at http://www-math.math.rwth-aachen.de/~LBFM/claus/ftape/ in the software section of that page.

To make a backup of your kernel source tree using tar, do this (assuming you have the sources in /usr/src/linux):

        # cd /usr/src
        # tar cf /dev/ftape linux

This will not compress the files, but gives you a smoother tape run. If you want the compression (and you've got tar 1.11.2), you just include the -z flag(*), eg: `tar czf /dev/ftape linux'

For further instructions on how to use tar, dd and mt look at the man pages and the texinfo files that comes with the respective distributions.

(*) tar assumes that the first argument is options, so the `-' is not necessary, i.e. these two commands are the same: `tar xzf /dev/ftape' and `tar -xzf /dev/ftape'

7.2 Restoring an archive

OK, let us restore the backup of the kernel source you made in section Writing an archive to a tape above. To do this you simply say

        tar xf /dev/ftape

If you used compression, you will have to say

        tar xzf /dev/ftape

When you use compression, gzip will complain about trailing garbage after the very end of the archive (and this will lead to a `broken pipe' message). This can be safely ignored.

For the other utilities, please read the man page.

7.3 Testing the archive

tar has an option (-d) for detecting differences between two archives. To test your backup of the kernel source say

        tar df /dev/ftape

If you do not have the man page for tar, you are not lost (yet); tar has a built-in option list: try `tar --help 2>&1 | less'

7.4 Putting more than one backup on a tape

To put more than one backup on a tape you must have the mt utility. You will probably have it already, if you got one of the mainline distributions (eg. Slackware or Debian).

Programs like tar and cpio generate a single Tape ARchive and know nothing about multiple files or positioning of a tape, it just reads or writes from/to a device. mt knows everything about moving the tape back and forth, but nothing about reading the data off the tape. As you might have guessed, combining tar or cpio with mt does the trick.

By using the nqft[0-3] (nftape) device, you can use `mt' to position the tape the correct place (`mt -f /dev/nqft0 fsf 2' means step over two ``file marks'', i.e. tar files) and then use tar or cpio to read or write the relevant data.

The most common use of the non-rewinding device is to append another backup to an existing tape. Here are the specific steps with a little explanation thrown in for good measure.

  • Insert a tape into the drive. On some devices this may cause the tape to be rewound.
  • Issue an End-of-Tape command to the NON-rewinding device.
            mt -f /dev/n???? eof
    
    The tape should now be positioned at the End-of-Data (EOD). The tape won't move unless a program opens the device, closes the rewinding device, removes the device driver from kernel memory (rmmod) or ejects the tape. Using `mt eof' may be faster on QIC tapes.
  • The next tape operation will start at the EOD mark. If you perform a write, it will append a new `file'. If you perform a read it will fail with EOF. The EOD mark on most tape formats is actually two consecutive EOF marks, however, since version 3.xx ftape uses the volume table as specified in the QIC-113 standard to emulate file marks, thus there aren't two consecutive file marks at EOD. Writing the EOF marks is handled by either the device driver or the hardware when a close() is performed.
  • Here's where you write the actual data to the tape.
  • Here's the important part. Now rewind the tape. Both ftape caches some information that belongs in the header segments on the tape and update those header segments only when the tape is rewound. This caching is necessary because rewinding the tape and updating the header segments takes a conspicuous amount of time. The drawback of this caching is that you will lose information if you have written to the tape and not rewound the device.

7.5 Appending files to an archive

``Is there a way to extend an archive -- put a file on the tape, then later, add more to the tape?''

No. The tar documentation will tell you to use `tar -Ar', but it does not work. This is a limitation of the current ftape driver.

7.6 Mount/unmounting tapes

Since a tape does not have a ``filesystem'' on it, you do not mount / unmount the tape. To backup, you just insert the tape and run your `tar' command (or whatever you use to access the tape with).


Next Previous Contents
Copyright © 2010-2024 Platon Technologies, s.r.o.           Home | Man pages | tLDP | Documents | Utilities | About
Design by styleshout