Backing up your system is the only means of being able to repair it if it suffers severe damage, if you accidentally delete some important system files, or if someone breaks into your system and intentionally deletes some files. You should also back up your daily use data (compressed audio, images, office documents, e-mails, address book, etc.) to be safe.
You should make your backups using an appropriate medium and keep them in a safe place. Such a place should be outside the place you usually work in, if possible. You can even have two backups, one on-site, and one outside. Generally speaking, you should make sure that you will be able to restore those backups if you want all this to be really useful.
You probably have everything you need already installed in your system. You should also keep a boot disk near at hand (you created one, didn't you?). Actually, you can make backups using only tar and, optionally, a compression tool such as gzip or bzip2. See an example in the section called “Backup Example Using tar”.
As an alternative, you can use specialized backup programs, such as Taper, Time Navigator, Arkeia, or Mandrake Linux's own drakbackup (Please refer to the section called “DrakBackup: Backup and Restore your System and Personal Files”).
Well, this might be the single most difficult question every system administrator asks himself when the time to back up comes. The answer depends on things such as: are you just backing up your personal data, your configuration files, or your whole system? How much time or space is it going to take? Will you be restoring your backup on the same machine/OS version, or on a different one?
Since this is a troubleshooting guide, we will try to focus on doing a backup that will allow us to quickly restore our system to the state it was before that terrible thing which rendered it unusable happened. Of course, you will need to make a backup of your personal data if you don't want to lose it, but... that's another story.
As a rule of thumb, you will need to back up the following directories: /etc, /home, /root and /var. If you do a complete backup of these directories, you will have saved not only your system configurations, but your data as well (in case you are wondering where your data is, it's located in the /home/your_user_name/ directory). Please keep in mind that this can take a long time to complete, but it is the safest bet.
A more sophisticated scheme would be to back up only the configuration files which have changed, skipping the ones which haven't. This will take more planning time, but will lead to quicker backups (and quicker restores, too). They will be “easier” to port from one machine/OS version to another.
Next, you will be presented with a list of the files you should pay the most attention to. Note that these lists are not exhaustive at all, especially if you have made lots of changes to your system[19]
Contains LILO's boot-loader configuration. LILO is the default in Mandrake Linux, if you happen to be using GRUB instead, the files to back up are the ones in the /boot/grub directory.
Contains the disks' partition table configuration and the associated mount points.
Contains the modules to load and their parameters according to your system's hardware. This might not be useful if restoring on a very different machine, but it might have some hints anyway.
Contains X's settings. X is the graphical core of GNU/Linux and all its desktop environments, as well as window managers.
Contains CUPS's settings. CUPS is Mandrake Linux's default printing system. If you don't use CUPS and you use the lpr printing system then back up /etc/printcap instead.
Sets the system environment and some programs that are executed upon system startup.
Sets the cron jobs to be executed periodically, for system maintenance tasks for example.
Sets the system's various run levels. Usually you won't need to back up these ones, except if you have added some personalized run levels or changed a default one.
Contains ssh settings. If you do secure remote access this file is very important to keep.
If you have a web server, an FTP server, or other servers, make a backup of their respective configuration files as well. Note that we cannot list them all because they are server-dependent.
In the /root directory and each user's home directory /home/user_name, the following directories:
Settings for Mozilla's family of programs. The Navigator's bookmarks, Messenger's mail filters, etc. Note that if you use Mozilla's Messenger, this directory also contains all your e-mail and newsgroups messages. You definitely don't want to lose these ones, do you?
If you use KMail this directory holds all your e-mail messages.
Contains personalized ssh settings. If you use ssh, backing this one up is a must.
You may also want to keep an eye on the following files:
Please note that we did not mention every single possible configuration file because we would need to write a whole book on that subject. For example, if you don't use Mozilla you need not back up Mozilla related files and directories. If you don't use ssh you don't need to back up ssh related stuff, and so on.
To summarize, back up all the configuration files of the programs you use and all of the configuration files you have changed. Also back up all your personal (and your system's users) data files. You won't regret it.
The other big question to answer. This depends on how much you want to back up, how fast you want to make your backups, how easy is the access to the backup media, and a large list of etceteras.
Generally speaking, you need media that is at least as large as the amount of information you want to back up, and fast enough so the whole process won't take forever to complete.
We will provide you with a brief description of available backup media options. These vary in capacity, reliability, and speed. You can combine backup medium according to your backup strategy, for example: tapes and CD-R/DVD+RW, hard disk and tapes, hard disk and CD-R/DVD+RW, etc., but bear in mind that your backup software may or may not support all of them.
This is not meant to be an exhaustive analysis of the different storage media available out there. Some things might change in the future; things such as expected media life were taken from the manufacturer's web sites and/or personal and community experience. Also, there might be many personal points of view on many matters such as price or speed for example.
Floppy, LS120 Floppy and ZIP Disks. Their capacity goes from 1.44 MB (for floppies), passing from 120 MB (for LS120 floppies), up to 750 MB (for ZIPs). They are easy to carry around (they fit in a shirt pocket) and generally speaking, slow but cheap media, though the price per MB ratio is not as good as that of optical media or tapes. Standard floppy disk drive in virtually every computer, LS120 and ZIP need special drives. Read/Write. Expected media life ranges from 4 or 5 years (for floppies) to 10 or maybe more years (for LS120 floppies and ZIP disks).
Removable Hard-Disk-Like Media. Other removable media exist (Castlewood's ORB, and IOMEGA's JAZ come to mind) that have good price/features balance and are suited for doing backups. Some were even publicized as “hard disk replacements” (JAZ for example), but when used as hard disks they might not last too long due to design constraints (they are not hard disk drives). Anyway, Your Mileage May Vary on these matters, just make sure you choose wisely (use common sense) according to your needs.
Optical Media. By “optical media” we mean CD-R, CD-RW, DVD-R, DVD+R, DVD-RW and DVD+RW. Their capacity goes from 650 or 700 MB (for CD media[20]) up to 4.7 GB (for DVD media). Very cheap and reliable media. Both CD and DVD recordable media today have the same price per MB. Write only once for R media and many times for RW media. Read as many as you want (well, actually, as you can...). Expected media life is 15 to 20 years, maybe more if they are stored in a safe place and read not too often.
Please bear in mind that the number of times optical media can be written and their life depends on many factors (like usage, storage conditions, media technology, media writing speed, etc.) which cannot be precisely stated. For example, some media cannot be reliably read if written at high speeds (like 10X for CD-RW), other media cannot be written more than 20 times, etc. Your mileage may vary.
Tape. Its capacity goes from 120 MB up to several gigabytes. Expensive and not very reliable media (they are magnetic tapes after all). Even so, their capacity makes them ideal to back up servers and the like; if you want to back up your whole disk drive in only one piece of media, tape might be the only way to go. Its biggest drawback is that tape access is sequential, and this has a big performance impact, but SCSI tape drives are fast enough for today's needs and they do have many gigabytes of space to store your files. Read/Write. Expected media life is up to 30 years for new tape technologies.
Hard Disk. Today's hard disk prices have dropped in such a way that they might be considered seriously as a backup medium, too. They are relatively cheap, have huge capacities (up to 250 GB at the time of writing this manual), are very reliable and the fastest of all media introduced in this list. If you have a laptop system this may not be an option[21], but on your desktop systems adding a spare disk drive just for backup purposes might be a good choice. Actually, you might not even need to add a new hard disk and do backups on the only hard disk you have; but this might not prove to be a good idea since it won't protect you from a hard disk crash.
Remote Directories. Well, this might not be considered strictly as “media”, but we will say a little about it because it is a good backup choice provided you have enough space and bandwidth. If your ISP provides you with some space you can use it to place your files along with your web pages. On the web you can find many offerings for online remote storage services. If you have a network with two or more machines you can do backups on some “remote” machine on the network (other than the one you are trying to back up, of course...). Actually, doing “remote” backups could be a security hole, so do not keep your top secret files, nor your most important ones, on a remote directory. Remember that, in the case of a major system failure, you may not even be able to connect to that remote site to recover your files...
There are many policies for backup schedules. We will introduce you to a few. Please bear in mind that these are not mandatory, nor the best ones, nor the only ones. These are just guidelines you may want to follow in rolling out your own backup schedule.
The many backup strategies out there depend on the media you use, on how often your data changes, and on how critical that data is to you or your organization. For example, one strategy states that you should make a full backup each weekend, and an incremental (changed stuff only) backup every day; then make a full backup every month and store that one in at least two places. This strategy might prove useful for an enterprise, but not for a personal computer. For your personal backups you can think of something like this: make a weekly backup of your files on your disk drive and each month transfer those backups to CD-R/DVD+RW or tape.
Next, we will introduce you to a little backup script that uses tar for making a complete backup of your home directory.
You need read permission on the files, and read and execute permissions on directories, you are going to back up. Otherwise the backup operation will fail.
#!/bin/bash # Create a compressed backup of your home directory in a file named # backup.tar.gz or backup.tar.bz2 depending on the compression scheme used. BACKUP_DIRS=$HOME # Uncomment the following line if you want GZipped backups #tar cvzf backup.tar.gz $BACKUP_DIRS # We do a BZipped backup here... tar cvjf backup.tar.bz2 $BACKUP_DIRS |
As you can see this is a very simple backup script that only does a backup of your home directory and puts the result into the very same directory. Let's enhance it a little...
#!/bin/bash # Create a compressed backup of all the directories specified and put the # resulting file in a directory of our choice. BACKUP_DIRS="$HOME /etc /etc/rc.d" BACKUP_FILENAME=`date '+%b%d%Y'` BACKUP_DEST_DIR="/backups" # Uncomment the following line for GZipped backups, comment for # BZipped backups #tar cvzf $BACKUP_DEST_DIR/$BACKUP_FILENAME.tar.gz $BACKUP_DIRS # We do a BZipped backup here... # Comment the following line for GZipped backups, uncomment for # BZipped backups tar cvjf $BACKUP_DEST_DIR/$BACKUP_FILENAME.tar.bz2 $BACKUP_DIRS |
As you can see in this last example, we have added some more directories to our backup, and we have used a naming scheme to add the date of the backup to the resulting filename.
Of course, you can later move the resulting tar.bz2 or tar.gz file to any media you want. You can even backup directly to the media you want by mounting it and changing the variable BACKUP_DEST_DIR of the script accordingly. Feel free to enhance this script and make it as flexible as you want.
To restore the backups made this way, please look at the section called “Restore Example Using tar”.
[19] If you have made lots of changes, you probably won't need these lists anyway.
[20] Even if there are the so-called “99 minutes” CD-Rs, they seem to have many compatibility and reliability problems with different CD recorders and CD-ROM drives.
[21] If you have a relatively new laptop, you may have space to install a second hard disk. Also, using USB, parallel port and FireWire, you can attach extra external hard disk drives.