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 backup 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 in place, 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 made 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 Section , “Backup Example Using tar”.
As an alternative, you can use specialized backup programs, such as Taper, Time Navigator, Arkeia, etc.
Well, this might be the single most difficult question every system administrator asks himself when the time to backup comes. The answer to it depends on things such as: are you just backing up your personal data, your configuration files, or your whole system? How much time and/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 that 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 is another story.
As a rule of thumb, you will need to backup the following directories: /etc, /home, /root and /var. If you do a complete backup of these directories, you will have saved not only your configurations, but your data as well (in case you are wondering where your data is, it is 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 backup only the configuration files that have changed, leaving alone the ones that have not changed. This will take more “planning” time, but will lend to quicker backups (and quicker restores, too) and to backups that are “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[16]
Contains LILO's boot loader configuration. LILO is the default in Mandrake Linux, if you happen to be using grub instead, the files to backup are the ones in the directory /boot/grub.
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 and window managers.
Contains CUPS's settings. CUPS is Mandrake Linux's default printing system. If you do not use CUPS and you use the lpr printing system then you must backup /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 various run levels of the system. Usually you will not need to backup these ones, except if you have added some personalized run levels or changed a default one.
Keeps 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 too. Note that we cannot list them all here because they are server-dependent.
In the directory /root and each user's home directory /home/user_name, the following directories:
Settings for Mozilla's family of programs. Navigator's bookmarks, Messenger's mail filters, etc. Note that this directory also holds all your e-mail and newsgroups messages. You definitely do not want to lose these ones, do you?
If you use kmail this directory holds all your e-mail messages. You definitely do not want to lose these ones either, do you?
Contains personalized settings for ssh usage. 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 do not use Mozilla you need not backup Mozilla related files and directories, if you do not use ssh you need not backup ssh related stuff, and so on.
Summarizing, backup all of the configuration files of the programs you use and all of the configuration files you have changed. Also backup all your personal (and your system's users) data files. You will not regret it.
The other big question to answer. This depends on how much do you want to backup, how fast do 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 backup, and fast enough so the whole process will not take forever to complete.
Next, we will provide you with a brief description of available backup media options. These vary in capacity, reliability, and speed. They are not given in any particular order, just as they come to mind. Please note that your backup software may or may not support all of them.
This list is not intended to be an exhaustive analysis of the different storage media available out there. In fact, some of the things written below 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.
Its capacity goes up to 1.44 MB[17]. They are easy to carry around but for today's needs they may not have enough room. Best way to carry small files. Slow. Cheap. Standard floppy disk drive in virtually every computer. Read/Write. Expected media life is 4 or 5 years.
Its capacity is 120 MB. Identical physical dimensions than floppy disks but with almost ten times more the capacity. Not so cheap. Needs a special floppy disk drive but this drive can also read/write standard floppy disks. Might be a good floppy replacement but it's speed lags behind that of ZIP drives. Read/Write. Expected media life is approximately the same as that of ZIP drives.
Its capacity goes up to 750 MB. Although not as thin as floppy disks, they are easy to carry around, too, and are more fitting for today's needs. Good balance of features, although it may be a little expensive. Read/Write. Expected media life is 10 years for 100 MB units, maybe more for 250/750 MB units.
Its capacity goes up to 700 MB these days[18], although the standard is 650 MB. Very cheap and reliable media. Today many argue that its capacity is not enough, but 650 MB is actually sufficient for most people. Its strongest feature is that almost every computer on earth has a CD-ROM drive, so they can be read almost everywhere. Write only once. Read as many as you want (well, actually, as you can...). Expected media life is 20 years, maybe more if they are stored in a safe place and read not too often.
Same considerations as for CD-R, but it can be formatted and re-written as many as 1000 times. All in all, cheap and reliable media. Expected media life is 15 years, maybe more if they are stored in a safe place and read not so often.
This is one of the newest additions to the available storage media. Its capacity is 4.7 GB for single sided recordable DVD discs. Drives are a little bit expensive but that is more or less compensated by the fact of being able to store 4.7 GB on a single disk. Expected media life is 15 years, maybe more if they are stored in a safe place and read not so often.
Its capacity goes from 120 MB (anyone has tape drives this old?) up to several gigabytes. Expensive and not very reliable media (they are magnetic tapes after all). Even so, their capacity makes them ideal to backup servers and the like; if you want to backup 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 room to store your files. Read/Write. Expected media life is up to 30 years for new tape technologies.
Today's 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 200 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[19], 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 will not protect you from a hard disk crash.
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, and ... good luck!
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 that space to place your files along with your web pages. You can find on the web 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 backup, 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...
Please bear in mind that you can also 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.
There are many policies for backup schedules. Here 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 permissions on the files, and read and execute permissions on directories, you are going to backup, 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 Section , “Restore Example Using tar”.
[16] If you have made lots of changes, you probably won't need these lists anyway.
[17] Well, actually they can be formatted at up to 1.92 MB using programs like SuperFormat and your standard floppy disk drive, but that's another story...
[18] Even if there are the so-called “99 minutes” CD-Rs, they seem to have many compatibility and reliability problems with different CD recorders.
[19] 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.