Chapter 2 Backups

Table of Contents
2.1 Backups Overview
2.2 Backup Media
2.3 Automating backups
Contributed by Justin Sherrill.

2.1 Backups Overview

If you are looking to save a relatively small number of files, you can use tar(1) to concatenate multiple files into a single archive. Optionally, then use a utility like gzip(1) to save on disk space or bandwidth used. Save the resulting file somewhere other than on the disk that contains the original files.

cpdup(1) can be used to backup/mirror an entire directory structure to a different disk.

Special files, whole filesystems, and incremental backups all require more specialized tools. For this, the tools dump(8) and restore(8) will handle almost any eventuality. dump() will copy a complete filesystem to the location specified; restore() will replace that filesystem into a clean partition. It is possible to completely reformat a hard drive that has been backed up with dump(), and then use restore() to bring that drive back completely to its original state.

dump() can dump a mounted disk to a single file:

 
      # dump 0af filename mountpoint
     

restore() can then recreate that data from the dumpfile:

 
      # restore rf filename
     

Note: When using the -r option, restore() rebuilds the filesystem described by the dumpfile. Only restore files using -r in an empty directory or clean mountpoint. Otherwise, any existing data could be overwritten.

The dumped data can be automatically placed in a compressed file, and restored while decompressing.

 
      # dump 0af - / | gzip > root.dump.gz
      # gunzip root.dump.gz | restore rf -
     

It's also possible to selectively restore files from a dump:

 
      # restore xf filename files_to_restore
     

Contact the Documentation Team for comments, suggestions and questions about this document.