Restoring from the Archive Once an archive has been created it is important to test the archive. The archive can be tested by listing
the files it contains, but the best test is to restore a file from the archive.
• To see a listing of the archive contents. From a terminal prompt type:
t a r −t z v f /mnt/ backup / host−Monday . t g z
• To restore a file from the archive to a different directory enter:
t a r −x z v f /mnt/ backup / host−Monday . t g z −C /tmp e t c / h o s t s
The -C option to tar redirects the extracted files to the specified directory. The above example will
extract the /etc/hosts file to /tmp/etc/hosts. tar recreates the directory structure that it contains.
Also, notice the leading “/” is left off the path of the file to restore.
• To restore all files in the archive enter the following:
cd /
sudo t a r −x z v f /mnt/ backup / host−Monday . t g z
Note This will overwrite the files currently on the file system.
References • For more information on shell scripting see the Advanced Bash-Scripting Guide
• The book Teach Yourself Shell Programming in 24 Hours is available online and a great resource for
shell scripting.
• The CronHowto Wiki Page contains details on advanced cron options.
• See the GNU tar Manual for more tar options.
• The Wikipedia Backup Rotation Scheme article contains information on other backup rotation schemes.
• The shell script uses tar to create the archive, but there many other command line utilities that can
be used. For example:
– cpio: used to copy files to and from archives.
– dd: part of the coreutils package. A low level utility that can copy data from one format to
another.
312
– rsnapshot: a file system snapshot utility used to create copies of an entire file system. Also check
the Tools - rsnapshot for some information.