The restoration of a backup depends on which program, media, and schedule you used to make it. We won't cover all the restore cases, but only mention that in order to recover your settings and data files, make sure that you restore the files and/or directories to the same places they were in when you made the backup.
Now, we will introduce a little script to restore the backup we made with tar using the script introduced earlier in Section 3.6, “Backup Example Using tar”.
![]() | Warning |
---|---|
You need write permissions on the files and directories you are going to restore. Otherwise the restore operation will fail. |
#!/bin/bash # Extract a compressed backup of all the directories specified # putting the backed up files into their original places. BACKUP_SOURCE_DIR="/backups" RESTORE_FILENAME=$1 # Uncomment the following line if you are restoring GZipped # backups #tar xvzf $BACKUP_SOURCE_DIR/$RESTORE_FILENAME # Restore a BZipped backup here... tar xvjf $BACKUP_SOURCE_DIR/$RESTORE_FILENAME
As you can see, this script is simple enough. All we have to do is to pass it the file name of the backup we want to restore as a parameter (just the file name, not the full path), and it restores the backed up files into their original locations. Make sure the script is executable: open a terminal and run chmod 700 restore.sh.
There is a way to be prepared in case of “total disaster”, and that is by making a full backup of your system. Programs such as mkCDrec can be very useful to get you up and running in a matter of minutes. You can find it, together with its documentation on the mkCDrec web site.
mkCDrec allows you to do multiple-CD-ROM volumes, disk cloning (copying the full contents of a disk or partition to another with similar characteristics — at least the same size), and many more.
In order to restore a system with mkCDrec you only have to boot with the first CD-ROM of the multiple-CD-ROM volume and then follow the on-screen instructions.