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 personal 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 Mandrakelinux's own Drakbackup.
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 do not want to lose it.
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 is located in the /home/your_user_name/ directory). Please bear 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 those configuration files which have changed, skipping the ones which have not. 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.
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 will not 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 will not take forever to complete.
Available backup media options 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.
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 and bzip2 for making a compressed backup of the list of directories you provide. Please read the script's comments for tips on its usage.
![]() | Warning |
---|---|
You need read permission on the files, and read and execute permissions on the directories, you are going to back up. Otherwise the backup operation will fail. |
#!/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 /var" 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 |
Use BACKUP_DIRS to specify the directories you want to include in the backup and BACKUP_DEST_DIR to specify the destination directory where the backup is going to be stored. Make the script executable: open a terminal and run chmod 700 backup.sh.
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”.