How To Make Backups In Tape Devices

Posted by Pavel | Posted in Linux Administration | Posted on 11-07-2012


After getting to my office and check my email, I found a message with a short and interesting question about how to make backups in tape devices.

To keep it short, the command used to manage tape devices is called ‘mt‘. It is this tool that allows us to control tape devices.

I am assuming that after attaching the tape, it is accessible through /dev/sr0.

Before starting, you might want to check the tape status to get information about the tape unit (this step is optional):

# mt -f /dev/sr0 status

If you we to see in which block we are:

# mt -f /dev/sr0 tell

Creating your backup:

First, let us rewind the tape

# mt -f /dev/sr0 rewind

Now, assuming we want to backup a directory called important_data , we do the following:

# tar czf /dev/sr0 important_data/

After it have completed, we can list the written files with this command

# tar tzf /dev/sr0

Restoring your backup

Assuming we want to restore our backup in the root (‘/’) directory, we would type the following

# cd /
# mt -f /dev/sr0 rewind
# tar xzf /dev/sr0 important_data

Now, let us rewind the tape and, if applicable, unload it.

# mt -f /dev/sr0 rewoffl

If we want to delete the information in the tape device, we type

# mt -f /dev/sr0 erase

And that’s basically how you do it. You might also want to check the man page of the ‘mt’ command in order to learn about a few more options that might come in handy while managing tape devices.

Write a comment