Restoring data from a backup is fairly straightforward when your system is fundamentally intact and you just need to recover a handful of lost files; you run the backup software in reverse, as it were. For instance, you use tar's -extract command rather than the -create command. In the case of tar, you must specify the files or directories you want to recover on the command line, or else the system will attempt to recover everything. For instance, you might type these commands to restore the /home/alice directory from a tape backup if you've accidentally deleted it:
# tar xvplf /dev/stO home/alice
Note Unless you use the -absolute-paths option totar when you create a backup, the program strips the leading slash (/) from directory names. Therefore, to restore data to its original location, you must first move into the root (/) directory. Alternatively, you can restore data to another location and then move it to its final destination. This latter approach is safer; if you mistype or forget to include a filename, restoring to another location guarantees that you won't overwrite newer files with older ones.
A more troubling problem is what to do when a system is so badly damaged that you can't use it to recover itself. For instance, how do you recover if your hard disk dies or if your system is compromised by an intruder? In the first case, you must get a new hard disk, and you obviously can't boot it into Linux until you've restored Linux, and you can't restore Linux without booting Linux—a chicken-and-egg problem. In the second case, you can't trust the programs on the hard disk, and so you must use another installation to recover. In both cases, and in many others, the solution is to use an emergency recovery system. These systems enable you to boot a second Linux system in order to work on your primary Linux system. These emergency systems can be useful for work other than emergency file restores, too; for instance, you might use one to edit a boot script if you've accidentally damaged it. This section describes several emergency recovery systems. Of course, you should be sure to test your emergency recovery system so that you know it will work when you need it.
Was this article helpful?