There are a variety of methods of performing backups with Linux. These include command-line tools included with every Linux distribution, such as ``dd'', ``dump'', ``cpio'', as well as ``tar''. Also available are text-based utilities, such as ``Amanda'' and ``Taper'', which is designed to add a more user-friendly interface to the backup and restore procedures. There are GUI-based utilities as well, such as ``KDat''. Finally, commercial backup utilities are also available, such as ``BRU'' and ``PerfectBackup+''. Any one of these backup solutions can provide protection for your valuable data.
A brief listing of some of the tools available, including where they can be obtained, can be found on the "Linux Applications and Utilities Page", at http://www.xnet.com/~blatura/linapp2.html#back. When deciding on a backup solution, you will need to consider the following factors:
Obviously, the procedures for performing a backup and restore will differ depending on your choice of a backup solution. However, in this section, I will discuss methods for performing backups with the two tools I use most: ``tar'' (whose name stands for "Tape ARchiver"), which is a command-line backup tool largely portable across *nix systems; as well as ``KDat'', a GUI-based tape backup utility which comes included with the KDE packages (see Section 5.6 for more information on KDE).
Finally, I should add that, depending on your choice of backup solution, even if the tool doesn't have the ability built-in to schedule automated or unattended backups, you may be able to automate such backups by using the cron facilities. See Section 9.4 for details on using cron and on creating crontab schedule files.
If you decide to use ``tar'' as your backup solution, you should probably take the time to get to know the various command-line options that are available; type "man tar" for a comprehensive list. You will also need to know how to access the appropriate backup media; although all devices are treated like files in the Unix world, if you are writing to a character device such as a tape, the name of the "file" is the device name itself (eg. ``/dev/nst0'' for a SCSI-based tape drive).
The following command will perform a backup of your entire Linux system onto the ``/archive/'' file system, with the exception of the ``/proc/'' pseudo-filesystem, any mounted file systems in ``/mnt/'', the ``/archive/'' file system (no sense backing up our backup sets!), as well as Squid's rather large cache files (which are, in my opinion, a waste of backup media and unnecessary to back up):
Don't be intimidated by the length of the command above! As we break it down into its components, you will see the beauty of this powerful utility.
The above command specifies the options ``z'' (compress; the backup data will be compressed with ``gzip''), ``c'' (create; an archive file is begin created), ``v'' (verbose; display a list of files as they get backed up), ``p'' (preserve permissions; file protection information will be "remembered" so they can be restored). The ``f'' (file) option states that the very next argument will be the name of the archive file (or device) being written. Notice how a filename which contains the current date is derived, simply by enclosing the ``date'' command between two back-quote characters. A common naming convention is to add a ``tar'' suffix for non-compressed archives, and a ``tar.gz'' suffix for compressed ones.
The ``--directory'' option tells tar to first switch to the following directory path (the ``/'' directory in this example) prior to starting the backup. The ``--exclude'' options tell tar not to bother backing up the specified directories or files. Finally, the ``.'' character tells tar that it should back up everything in the current directory.
Another example, this time writing only the specified file systems (as opposed to writing them all with exceptions as demonstrated in the example above) onto a SCSI tape drive follows:
In the above command, notice that the ``z'' (compress) option is not used. I strongly recommend against writing compressed data to tape, because if data on a portion of the tape becomes corrupted, you will lose your entire backup set! However, archive files stored without compression have a very high recoverability for non-affected files, even if portions of the tape archive are corrupted.
Because the tape drive is a character device, it is not possible to specify an actual file name. Therefore, the file name used as an argument to tar is simply the name of the device, ``/dev/nst0'', the first tape device on the SCSI bus.
Since we aren't able to specify a filename for the backup set, the ``--label'' option can be used to write some information about the backup set into the archive file itself.
Finally, only the files contained in the ``/etc/'', ``/home/'', ``/usr/local'', and ``/var/spool/'' (with the exception of Squid's cache data files) are written to the tape.
When working with tapes, you can use the following commands to rewind, and then eject your tape:
If you are using the KDE desktop environment, I believe you will find the ``KDat'' utility both powerful as well as user-friendly. In addition, an added bonus is that KDat uses ``tar'' as its backup engine. Therefore, backup sets written with KDat can be read not only with KDat but with tar as well! This makes KDat a very nice choice for both user-friendliness as well as backup portability.
The first time you run the KDat program, you will need to create a backup profile. Such a profile tells KDat which files on your system you would like to back up. If you wish, you can create more than one backup profile, depending on your needs (for example, you could create a profile called "Full Backup" for a full system backup, and "Quick Backup" for a backup of user files only).
To create a backup profile, either choose "Create Backup Profile" from the "File" option on menu bar (or right-click on the "Backup Profiles" folder, then choose "Create Backup Profile"). On the right hand side of the KDat window, you can change various settings, such as the profile name, archive name, tar options, as well as others. Click the "Help" menu for more information on what these settings are for.
To specify which files should be included in your backup profile, left-click the checkbox beside the ``/'' directory folder. This will enable all files in and below this directory for backups. Then, left-click on the small ``+'' sign beside the folder. This will expand the folder, showing a list of files in and below it. This will allow you to exclude any files you do not wish to backup; simply left-click the checkbox beside each file or directory you wish to exclude. For example, a full backup should probably have every file and directory checkmarked, with the exception of the ``/proc'' (a pseudo-filesystem containing information about your running system), ``/mnt'' (a directory below which CD-ROM drives, floppies, and network shares are usually mounted), and, if you are a Squid user, ``/var/spool/squid'' (Squid's cache data files). Once you have selected the appropriate files, left-click on the backup profile you are creating, then left-click the "Files >>" button to move the selected files list to your backup profile.
To actually perform a backup, insert a tape into the drive, and then choose "Mount Tape" from the "File" menu (or left-click the icon that looks like a tape). This will "mount" the tape (actually, because a tape device is a character device, it isn't actually possible to mount it -- what KDat actually does is to first rewind the tape, attempts to read in header information, and if successful, find the corresponding tape index on your hard drive. Otherwise, KDat will prompt you to format the tape.
Once KDat has mounted the tape, before you start the backup you must first choose the backup profile you wish to use for the backup. To start the backup, simply right-click on the desired backup profile, and then left-click on the "Backup" option. KDat will first display a dialog box showing you the details of the backup profile you have selected; left-click the "Ok" button to start the backup.
While the backup is in progress, KDat will display a dialog box showing various statistical information (elapsed time, backup size, backup rate, estimated time remaining, as well as the number of files and total bytes written), and display a list of files as they are backed up. A full backup containing several gigabytes of data might take several hours to complete. If you find it necessary, you can left-click the "Abort" button at any time to interrupt the backup process.
Once the backup is complete, you can unmount the tape by choosing "Edit" from the menu bar, and then "Unmount Tape", or left-click on the tape icon, which will rewind and eject the tape.