Chapter 3. Native Backup & Recovery Utilities

Native utilities are the backup utilities that you find in a standard Unix distribution. I’ll admit that these utilities are rather boring. They do nothing fancy and they have many limitations, some of which have been there since they were originally written to back up a PDP-11 to a 9-track tape. (In sixth and seventh edition Unix, it was still called restor —a throwback to the Multics days.) Some of these utilities have bugs that persist to this very day. (They’ve finally fixed the “tape-rewinding” bug in dump, but only on some Unix versions.)

Yet these native backup utilities do have a few features that have not been duplicated by commercial backup vendors. These features will always be there, and they don’t cost extra. They also work basically the same everywhere, with only a few minor differences. Whether you’re just starting out in the backup world or you’re an experienced systems administrator, you need to be familiar with these utilities.

An Overview

This chapter describes the benefits and pitfalls of several utilities. dump and restore are usually the best option if they are available. After dump and restore, cpio has the best functionality, but it is slightly less user friendly than its cousin tar. tar is incredibly easy to use and is much more portable than either dump or cpio. If you have to back up raw devices or perform remote backups with tar or cpio, dd will be your new best friend.

This chapter begins with an overview of each of these backup utilities. It then goes into detail about the syntax for each command for both backup and recovery. Finally, near the end of the chapter, there is an invaluable comparison chart that can be used as a quick reference guide for comparing dump, tar, and cpio.

The dump and restore Utilities

If you are responsible for backing up at least one Unix server, can’t afford a commercial backup product, and don’t want to trust your mission-critical backups to a public domain utility, then hopefully your version of Unix supports the commands dump and restore. You can’t beat their flexibility and versatility for backing up and restoring an entire system. dump and restore are relatively sophisticated commands, with simple interfaces whose essential options are the same on most Unix systems. Some versions of Unix have changed the name and a few of the features of dump, but most of the changes are minor.[9] dump can even be found on Unix-like systems such as Linux[10] and Network Appliance boxes. Even if you don’t plan on using dump for backups in the future, chances are you’ve got several dump volumes in a cabinet somewhere that you may need to read someday. When you do need to read those volumes, hopefully you will have this book handy.

The cpio Utility

If you do not have dump or you can’t use the version you have, then cpio is your next best choice. cpio has been around longer than any other backup utility and has some very important features that other commands do not have. First, there are a few things that cpio will not do for you that dump can. cpio cannot:

  • Perform incremental backups without the use of touch files and find

  • Leave both atime and ctime unchanged after a backup (see the section on mtime, atime, and ctime in Chapter 2)

  • Perform an interactive restore, like the -i option in restore

cpio can be a very powerful backup tool. The main thing that sets it apart is its ability to accept the list of files to be backed up from standard input.

Tip

Some newer versions of tar support listing the files via standard input, but most native versions of tar do not support it. See Section 3.2 in this chapter for more details.

Why isn’t cpio more popular?

If cpio is so wonderful, why is tar more popular? The most probable reason is that the basic operations of tar are much simpler (and more standard) than the same operations in cpio. For example, every version of tar supports tar cf device and tar xf device, whereas cpio sometimes supports the -I and -O options and sometimes does not. If you add all the cpio options available on all the various versions, you would find more than 40 of them. There are also some arguments that use the same letter but have completely different functions on different versions of Unix. However, I believe that if you use only the options that are standard on most (if not all) platforms, cpio can have almost the same simplicity as tar —almost.

The tar Utility

If you need to back up your entire system on a regular basis, dump is probably your best choice if it is available. Your second best choice is cpio, since you can use it with find to perform incremental backups. But if you’re like most people, you do a whole lot of backups that don’t need this level of functionality. You may want to make a quick backup of a user’s home directory. The user has a huge directory that you would love to delete, but the only way she’ll let you back up her directory is if you give him a copy of it on a tape or CD. You don’t care about atime ; you don’t want to do regular, incremental backups; you just want to get the stuff onto a backup volume, and you want it to be easy for someone else to get it off the backup volume. In this case, tar is your best bet.

There are some things that cpio can do for you that most native versions of tar can’t (GNU tar does not have these limitations, thanks to a lot of work from a lot of people. See the sidebar on GNU tar later in this chapter.):

  • Accept a list of files to back up from stdin. (Again, a few native versions of tar support this. See the section on tar later in this chapter for more details.)

  • Reset atime of the files it backs up, although this changes ctime . The native versions of tar are not able to reset atime, but the GNU version of tar can.

Although tar hasn’t been around as long as cpio, it has gained much wider acceptance. This is perhaps its greatest feature. Nearly everyone knows how to read a tar volume, and if they don’t it’s really easy to show them how. If it is a tar file on disk or even a compressed tar file, programs like WinZip[11] can automatically decompress it and read what’s inside. (WinZip cannot open a cpio archive.) It is also much more portable between Unix platforms than dump or cpio.[12]

The dd Utility

The dd command is not a backup command used by most people. It is a very low-level command and is designed for copying bits of information from one place to another. It does not have any knowledge of the structure of the data it is copying—it doesn’t need to. Therefore, unlike dump, tar, and cpio, it is not used to copy a group of files to a backup volume. It can copy a single file, a part of a file, a raw partition, or a part of a raw partition, and can even copy data from stdin to stdout while modifying it en route. Again, although it can copy a file, it has no knowledge of the filename or contents once it has done so. It simply copies the bytes that are in the place from which you told it to copy. It then puts those bytes where you told it to put them.

Although it is rather simplistic in this manner, it is extremely flexible. It can copy files or partitions regardless of format. It can translate data between two different platforms, such as EBCDIC to ASCII, or big endian to little endian.[13] A perfect example of dd ’s flexibility is the Oracle backup script included in Chapter 15. Oracle data is allowed to be in files in the filesystem or on raw disk partitions. Since the script could not predict which configuration each DBA would use, it used dd, since it is able to copy both files and raw partitions. That way the DBA can use whichever configuration makes most sense for his application, and the script will automatically back up either configuration. It even backs up a mixed configuration, where some of the data sits on files and some sits on raw partitions. This is the kind of flexibility that dd gives you.

Other Utilities

There are other native backup utilities that are less well known or are available only on certain platforms. The most popular among these are listed here:

pax

The portable archive exchange, or pax, utility produces a portable archive that conforms to the Archive/Interchange File Format specified in IEEE Std. 1003.1-1988. pax also can read and write a number of other file formats such as tar or cpio. Like many things in the Unix world, pax has a group of devoted followers that swear it’s the best way to go.

fbackup

The fbackup utility is available only on HP-UX and is the utility that HP’s System Administration Menu (SAM) supports. Backups made with this utility can be read only on another HP-UX machine using frecover . Although the utility does have several advantages over traditional cpio and tar, I do not like its complete lack of portability. Even though you can’t use SAM to perform a dump, cpio, or tar backup, I believe the portability of these three commands is worth the extra effort that it takes to use them.

Tip

The explanation of dump, tar, cpio, and dd that follow are not meant to replace the manpages for those commands on your particular version of Unix. The syntax here should work on most Unix platforms, but you definitely should become familiar with the manpages for your Unix platform(s). They may contain anything from minor to major caveats for that particular OS. In some cases, vendors document an extra feature or two. Always stay up to date with the manpages for your backup command—whatever it is.



[9] Some, however, include major modifications, and in some respects dump is not really dump at all! Let the user beware! Make sure you read the manpages for your version of dump.

[10] Remember that Linux is just like Unix, but it doesn’t carry the Unix brand. Therefore, it is Unix-like.

[11] WinZip is a registered trademark of Nico Mak Computing, Inc. You can download a demo version from their web site at http://www.winzip.com.

[12] The DJGPP project, a port of gcc and the GNU tools and utilities suites to MS-DOS and Windows, made cpio its portable archive standard and has ported both GNU cpio and GNU tar to DOS and Windows as 32-bit executables.

[13] The concept of big endian/little endian is explained in detail in Section 3.10.6 later in this chapter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.130.24