UNIX System Administration Handbook - Evi Nemeth [113]
10.3 SETTING UP AN INCREMENTAL BACKUP REGIME
The dump and restore commands are the most common way to create and restore from backups. These programs have been part of UNIX for a very long time, and their behavior is well known. At most sites, dump and restore are the underlying commands used by automated backup software.
Dumping filesystems
The dump command builds a list of files that have been modified since a previous dump, then packs those files into a single large file to archive to an external device. dump has several advantages over the other utilities described later in this chapter:
• Backups can span multiple tapes.
• Files of any type (even devices) can be backed up and restored.
• Permissions, ownerships, and modification times are preserved.
• Files with holes are handled correctly.4
• Backups can be performed incrementally (with only recently modified files being written out to tape).
The dump command understands the layout of raw filesystems, and it reads a filesystem’s inode tables directly to decide which files must be backed up. This knowledge of the filesystem allows dump to be very efficient, but it also imposes a few limitations.5
The first limitation is that every filesystem must be dumped individually. If you have a disk that is partitioned, you must dump each partition separately. The other limitation is that only filesystems on the local machine can be dumped; you cannot dump an NFS filesystem mounted from a remote machine. However, you can dump a local filesystem to a remote tape drive with dump’s evil twin, rdump.
See Chapter 17 for more information about NFS.
The most important feature of dump is its support for the concept of an “incremental” backup. Although it is possible to back up the entire system each day, it is usually not practical. Incremental dumps make it possible to back up only files that have changed since the last backup.
When you do a dump, you assign it a backup level, which is an integer from 0 to 9. A level N dump backs up all files that have changed since the last dump of level less than N. A level 0 backup places the entire filesystem on the tape. With an incremental backup system, you may have to restore files from several sets of backup tapes to reset a filesystem to the state it was in during the last backup.6
Another nice feature of dump is that it does not care about the length of filenames. Hierarchies can be arbitrarily deep, and long names are handled correctly.
dump accepts many arguments, but they do not vary too much from platform to platform. We briefly describe the flags you will probably need to dump a network of machines. However, you must check these flags against the man pages on the machine where you are dumping because most vendors have tampered with the meaning of at least one flag.
dump parses its arguments differently from most other UNIX commands. It expects all the flags to be contained in the first argument, and the flags’ arguments to follow in order. For example, where most commands would want -a 5 -b -c 10, dump would want abc 5 10.
The first argument to dump must be the incremental dump level. dump uses the /etc/dumpdates file to determine how far back an incremental dump must go. The u flag causes dump to automatically update /etc/dumpdates when the dump completes. The date, dump level, and filesystem name are recorded. If you never specify the u flag, all dumps become level 0s because no record of having previously dumped the filesystem will ever be created. If you change a filesystem’s name, you can edit the /etc/dumpdates file by hand.
dump sends its output to some default device, usually the primary tape drive. If you want to use a different device, use the f flag to tell dump to send its output elsewhere. If you are placing multiple dumps on a single tape, make sure you specify a non-rewinding tape device (a device file that does not cause the tape to be rewound when it is closed—most tape drives