Neglecting to clean, align, and maintain tape drives puts your data at risk. The tapes themselves are also susceptible to mechanical wear and degradation. Hardware maintenance is part of a good backup policy. Do not ever forget that it is a question of when — not if — hardware will fail.
Using Backup Software
Because there are thousands of unique situations requiring as many unique backup solutions, it comes as no surprise that Linux offers many backup tools. Along with command-line tools such as tar and dd, Fedora also provides a graphical archiving tool, File Roller, that can create and extract files from archives. Finally, Fedora provides support for the Amanda backup application—a sophisticated backup application that works well over network connections and can be configured to automatically back up all the computers on your network. Amanda works with drives as well as tapes. The book
The software in a backup system must support the hardware, and this relationship can determine which hardware or software choices you make. Many sysadmins choose a particular backup software not because they prefer it to other options, but because it supports the hardware they own.
The price seems right for free backup tools, but consider the software's ease of use and automation when assessing costs. If you must spend several hours implementing, debugging, documenting, and otherwise dealing with overly elaborate automation scripts, the real costs go up.
tar: The Most Basic Backup Tool
The tar tool, the bewhiskered old man of archiving utilities, is installed by default. It is an excellent tool for saving entire directories full of files. For example, here is the command used to back up the /etc directory:
# tar cvf etc.tar /etc
Here, the options use tar to create an archive, are verbose in the message output, and use the filename etc.tar as the archive name for the contents of the directory /etc.
Alternatively, if the output of tar is sent to the standard output and redirected to a file, the command appears as follows:
# tar cv /etc > etc.tar
The result is the same.
All files in the /etc directory will be saved to a file named etc.tar. With an impressive array of options (see the man page), tar is quite flexible and powerful in combination with shell scripts. With the -z option, it can even create and restore gzip compressed archives, whereas the -j option works with bzipped files.
tarIf you want to create a full backup,
# tar cjvf fullbackup.tar.bz2 /
creates a bzip2-compressed tarball (the j option) of the entire system.
To perform an incremental backup, you must locate all the files that have been changed since the last backup. For simplicity, assume that you do incremental backups on a daily basis. To locate the files, use the find command:
# find / -newer
When run alone, find generates a list of files systemwide and prints it to the screen. The ! -a -type eliminates everything but regular files from the list; otherwise, the entire directory would be sent to tar even if the contents were not all changed.
Pipe the output of the find command to tar as follows:
# find / -newer
tar czT - backup_file_name_or_device_name
Here, the T - option gets the filenames from a buffer (where the - is the shorthand name for the buffer).
The tar command can back up to a raw device (one with no file system) as well as a formatted partition. For example,
# tar cvzf /dev/hdd /boot /etc /home
backs up those directories to device /dev/hdd (not /dev/hda1, but to the unformatted device itself).
The tar command can also back up over multiple floppy disks:
# tar czvMf /dev/fd0 /home
backs up the contents of /home and spreads the file out over multiple floppies, prompting you with this message:
Prepare volume #2 for '/dev/fd0' and hit return:
tarThe xp option in tar restores the files from a backup and preserves the file attributes as well, and tar creates any subdirectories it needs. Be careful when using this option because the backups might have been created with either relative or absolute paths. You should use the tvf option with tar to list the files in the archive before extracting them so that you know where they will be placed.
For example, to restore a tar archive compressed with bzip2,
# tar xjvf fedoratest.tar.bz2
To list the contents of a tar archive compressed with bzip2,
# tar tjvf fedoratest.tar.bz2
drwxrwxr-x paul/paul 0 2003-09-04 18:15:05 fedoratest/
-rw-rw-r-- paul/paul 163 2003-09-03 22:30:49 fedoratest/fedora_screenshots.txt
-rw-rw-r-- paul/paul 840 2003-09-01 19:27:59 fedoratest/fedora_guideline.txt
-rw-rw-r-- paul/paul 1485 2003-09-01 18:14:23 fedoratest/style-sheet.txt
-rw-rw-r-- paul/paul 931 2003-09-01 19:02:00 fedoratest/fedora_TOC.txt
Note that because the pathnames do not start with a backslash, they are relative path names and install in your current working directory. If they were absolute pathnames, they would install exactly where the paths
