Home > Articles > Software Development & Management

  • Print
  • + Share This
Like this article? We recommend

Using the Unix and Linux Standard Tools

If you are running a Unix or Linux system, then you already have some pretty standard and simple backup tools at your disposal. The most popular by far are cpio and tar. Backing up an entire system with these is pretty simple. Assume a tape drive gets created as /dev/st0. That's what it looks like on a Linux system. On AIX, you might get something like /dev/rmt0, while HP-UX might deliver /dev/rmt/0m. All these systems have the basic commands I mentioned. With tar, capturing the whole system means changing to the root directory and issuing a command like this one:

cd /
tar -cvf /dev/st0 .

Note the dot at the end, meaning "start with the current directory"—in this case, root. To restore a file, I would use this version of the tar command:

tar -xvf /dev/st0 path_to_lost_file

cpio is a little different. In its simplest form, you pass a list of files to the program using the find command.

find . -print | cpio -ov > /dev/st0

Restoring the file is not much more complicated than tar.

cpio  -iv path_to_lost_file < /dev/st0

Frankly, this is an easy way to do things, and scripting the command into something you can run nightly can be quite simple with a little shell magic. The basic Linux and Unix shell language provides for great flexibility in options and reporting. For instance, this entry in the system crontab (which you edit with the command crontab -e) would run the backup script called full_back every night at 1 a.m.

0 1 * * */usr/local/bin/full_back 1>/dev/null2>/dev/null

All you have to do is make sure that you put a tape in the drive before you head home for the night (or at least before 1 a.m., if you happen to be working late), and remove it the next morning.

This method tends to lend itself primarily to single-system backups. You could mount nfs drives and capture remote system data that way.

  • + Share This
  • 🔖 Save To Your Account