The dump utility is a simple, powerful backup tool from the early days of Linux. Where most backup programs operate on a per-file basis, dump backs up specific file systems.
A tool such as tape archiver, or tar, can be pointed at a directory of files and told to create an archive of that resource. That function has its place, but dump operates on a broader scale. The proper tool depends on the backup goal and, ultimately, the restore requirements.
Dump offers a huge advantage over cpio, tar and other similar utilities due to how it handles incremental backups. Once a full backup is run, incremental backups just copy files that have changed or been created since the full backup. This makes subsequent backup jobs run more quickly -- an advantage on slower machines with large file systems.
Dump has a few specific features that set it apart, as well as some key system requirements to note. Dump requires ext2, ext3 or ext4 file systems. This could be a compatibility concern on some modern distributions that use the XFS file system.
Below, new and existing Linux users will learn more about the dump utility, including how to install it, the different ways to use it for backups and how to use the restore tool to recover a backed-up file system.
Decide what to back up
When asked, "What should you back up?" many users will say, "Everything." However, that's not necessarily true -- especially on large systems and with today's quick, automated system deployments.
In many cases, the only thing necessary to back up is user data, such as the contents of /home. Operating system files don't always need to be backed up. However, you might need to back up custom configuration files for specific services, such as Apache, DNS or DHCP.
Install dump and restore
The dump utility might not be installed on your current distribution. Use your distro's package manager to add it.
For example, on Red Hat and similar distributions, type the following.
$ sudo dnf install dump
On Debian and similar distros, use the following.
$ sudo apt install dump
Remember that dump only recognizes ext* file systems. Use one of the following commands to confirm that the system uses ext4, ext3 or ext2.
$ df -Th
$ lsblk -f
Select backup options
Like other Linux commands, dump supports parameters, a destination target and a source target.
Basic dump syntax is as follows.
dump parameters destination-target source-target
The destination-target is where the backup job will be stored. The source-target is the file system you're backing up.
Before getting into the specific steps of conducting a backup with dump, consider the following parameters and other settings.
Dump expects a level value as part of the command. These levels specify the type and order of related full and incremental backups. A level 0 backup is a full backup job, meaning that it backs up the entire file system, regardless of changes. This is the initial backup job.
Levels 1-9 identify specific backup jobs. Dump uses these levels to decide what new or changed files to back up. It accomplishes this by comparing backup levels with any jobs with a smaller level.
A dump backup run at level 3 will grab any new or changed files since the level 2 backup. A level 4 backup picks up file changes since level 3. Depending on the backup frequency, an administrator could run a level 0 backup on Monday, then level 1 on Tuesday, level 2 on Wednesday and so on. This approach provides an incremental backup structure.
Dump expects additional parameters. These are spelled out in the related Linux manual page. There are two primary parameters to work with: The first is level, and the second is the -f option, which specifies the target storage location for the backup job.
Because dump is an older utility, it accepts many options oriented on end-of-tape settings for magnetic tape swapping. It can create backup jobs that span media, such as multiple tapes.
Dump can help determine whether a backup is necessary. Using a combination of /etc/fstab and /etc/dumpdates, it displays file systems that have changed and are, therefore, worthy of a backup. Use the -W option to generate this information.
$ sudo dump -W
In /etc/fstab, mark the file systems that dump should recognize and track for changes. Set the fifth column to 1 for each file system entry in /etc/fstab that dump should manage. It does this in conjunction with the /etc/dumpdates file.
Run a backup job
Suppose you deploy a Linux file server to host user home directories. All home directories are in the standard /home location, making it a perfect target for backing up with dump. Be sure any directories on the destination storage disk already exist, as dump won't create them.
After running the dump -W command to check whether a backup is worthwhile, run a basic level 0 dump.
$ dump 0f /dev/sdb1 /dev/sda1
Wait for the backup job to complete. Dump displays periodic status updates and a complete message when the backup finishes.
Back up to a network location with rdump
In this example, the storage location for the backup job is a locally mounted file system. Use the rdump utility to send backup jobs to network-mounted storage devices. This is a common option with modern networks.
The syntax for targeting a network location to store the backup job is similar to that of other services. Specify the remote system and an absolute path to the storage location. Make sure any necessary directories exist before initiating the backup.
To back up /home to a directory named /recovery/backups on a remote server named fileserver09, type the following.
$ rdump 0uf fileserver09:/recovery/backups /home
Back up to disk image
Another alternative storage location is backing up to a disk image created with the dd command. This utility has many uses. In this case, use the command below to create a 2 GB storage location for a dump backup job that emulates a separate drive but is actually just a file.
$ dd if=/dev/zero of=backup.img bs=1 count=0 seek 2G
Use the backup.img file as the destination for the dump backup archive.
$ dump 0f /media/backup.img /dev/sda1
What is restore?
A hardware failure or corrupted file system could cause you to restore a file system. In the previous scenario, you backed up the /home file system on a file server. Use the following steps to restore this information.
Basic restore syntax is as follows.
restore rf backup-source
The specified path is the storage location for the backup job. In other words, you used the dump command to write the archive to /dev/sdb1, and now you need to restore the archive from that location. The restore is written to the user's current location.
Decide what to restore and select restore options
Dump backs up an entire file system. The restore command, however, includes options for specifying individual files to restore. Use the command's parameters to identify the files you want to restore. However, the assumption with dump and restore is that you are working at the file system level, not at the file level.
The restore command offers flexibility in viewing and extracting archive contents -- or restoring files.
|Extract the entire archive to the current directory.
|The next object is the backup job location.
|List the names found in the archive.
|Compare the archive with the current directory.
|Extract only the specified files instead of the entire archive.
|Display verbose output.
The restore process consists of the following steps:
- If necessary, install and configure Linux on a new system.
- Mount a formatted disk and change to that mount point.
- Use the restore tool to recover the file system.
For example, the restore command might look like the following.
$ restore rf /dev/sdb1
No destination is defined because the restore writes to the user's current location. Use pwd to make sure the restore goes to the intended directory.
Restore from a network location with rrestore
Users will need to use the rrestore command if the backup job resides on a network share based on using the rdump command above.
The rrestore syntax looks like the following, assuming the same storage location used in the rdump example earlier.
$ rrestore rf fileserver09:/recovery/backups
Use dump and restore today
Modern Linux users will likely be familiar with tar and perhaps cpio for backups. These utilities can target specific files and directories for backup. Downloads of multiple files are usually bundled into tarballs, making them even more common.
The dump utility operates in a different space. It archives all or some of a file system as a single resource, making it efficient for large-scale storage devices such as file servers. Dump is paired with the recovery tool restore, which can extract individual files from the backup job or recover the entire file system. Managing backups and restores across the network is also extremely beneficial.
Dump's ability to create full, incremental and differential backups aids in efficient recovery and economical use of storage capacity on backup media.
Many Linux -- and Unix and BSD -- systems still use the ext4 file system and benefit from dump's flexibility and customization.
Damon Garn owns Cogspinner Coaction and provides freelance IT writing and editing services. He has written multiple CompTIA study guides including the Linux+, Cloud Essentials+ and Server+ guides, and contributes extensively to TechTarget Editorial and CompTIA Blogs.