Ubuntu Linux backup of a laptop using a USB enclosure and the dump utility

Earlier, I wrote about how to use a USB 2.0 hard disk drive enclosure for backup.

In this article, I explain how to use that hard disk using the dump utility.

The dump utility

The dump utility is one of the oldest commands for backup on UNIX system, but not one that is widely used in home and small business Linux systems.

In a nutshell, the dump utility works on the file system level, and can handle incremental backups. By incremental backups, I mean that only files that have changed since the last lower level backup will be included. This has the benefit of backing up only the changes to a system, and consumes less time and space than a full backup.

The dump utility does this by "levels". Level zero means full backup. Level 1 means all files changed since the last level 0 backup was performed. Level 2 means files changed since the last Level 1 or 0 was performed, and so on until level 9.

For example, one would perform a level 0 backup every week on Sunday, and a level 1 every day until the following Sunday. Other schemes are possible, for example Towers of Hanoi plan.

Caution: Quiescent file system recommended

It should be noted that backup should be performed on a quiescent file system with no activity on it. Ideally, the file system should be unmounted to ensure that the data in it is not being changed.

Installation of dump

Note that each file system type has a different dump program. The default dump program works for the ext2 and ext3 file systems, and that is what I will cover in this article. Other file systems such as ReiserFS or XFS have their own dump with a similar syntax.

To From the command line using a root shell, do the following:

aptitude install dump 

Now you have the programs that are needed for backup.

Performing a dump

This script performs a level 0 backup (full) on the root file system:

#!/bin/sh
DIR=/media/extdisk0
DATE=`date +%Y-%m-%d`
FILE=full-$DATE.dump

dump -0 -u -b 64 -f $DIR/$FILE /

To perform a level 1 backup, you can use the command:

dump -1 -u -b 64 -f /media/extdisk0/dump-1.dump 

Dump is quite verbose and outputs useful information like estimated time to complete, size of data backed up, and time it took to backup.

Here is a sample from a level 0 dump:

  DUMP: Date of this level 0 dump: Sun Jan 28 02:39:53 2007
DUMP: Dumping /dev/sda6 (/) to /media/extdisk1/backup/backup-l0-2007-01-28.dump
DUMP: Label: none
DUMP: Writing 64 Kilobyte records
DUMP: mapping (Pass I) [regular files]
DUMP: mapping (Pass II) [directories]
DUMP: estimated 22545911 blocks.
DUMP: Volume 1 started with block 1 at: Sun Jan 28 02:41:20 2007
DUMP: dumping (Pass III) [directories]
DUMP: dumping (Pass IV) [regular files]
DUMP: 18.66% done at 14021 kB/s, finished in 0:21
DUMP: 45.57% done at 17122 kB/s, finished in 0:11
DUMP: 73.43% done at 18395 kB/s, finished in 0:05
DUMP: 96.73% done at 18173 kB/s, finished in 0:00
DUMP: Closing /media/extdisk1/backup/backup-l0-2007-01-28.dump
DUMP: Volume 1 completed at: Sun Jan 28 03:01:55 2007
DUMP: Volume 1 22512512 blocks (21984.88MB)
DUMP: Volume 1 took 0:20:35
DUMP: Volume 1 transfer rate: 18228 kB/s
DUMP: 22512512 blocks (21984.88MB) on 1 volume(s)
DUMP: finished in 1235 seconds, throughput 18228 kBytes/sec
DUMP: Date of this level 0 dump: Sun Jan 28 02:39:53 2007
DUMP: Date this dump completed: Sun Jan 28 03:01:55 2007
DUMP: Average transfer rate: 18228 kB/s
DUMP: DUMP IS DONE

And here is a sample from a level 1 dump:

  DUMP: Date of this level 1 dump: Sat Feb  3 02:03:05 2007
DUMP: Date of last level 0 dump: Sun Jan 28 02:39:53 2007
DUMP: Dumping /dev/sda6 (/) to /media/extdisk1/backup/backup-Sat.dump
DUMP: Label: none
DUMP: Writing 64 Kilobyte records
DUMP: mapping (Pass I) [regular files]
DUMP: mapping (Pass II) [directories]
DUMP: estimated 385410 blocks.
DUMP: Volume 1 started with block 1 at: Sat Feb 3 02:05:32 2007
DUMP: dumping (Pass III) [directories]
DUMP: dumping (Pass IV) [regular files]
DUMP: Closing /media/extdisk1/backup/backup-Sat.dump
DUMP: Volume 1 completed at: Sat Feb 3 02:06:22 2007
DUMP: Volume 1 383616 blocks (374.62MB)
DUMP: Volume 1 took 0:00:50
DUMP: Volume 1 transfer rate: 7672 kB/s
DUMP: 383616 blocks (374.62MB) on 1 volume(s)
DUMP: finished in 50 seconds, throughput 7672 kBytes/sec
DUMP: Date of this level 1 dump: Sat Feb 3 02:03:05 2007
DUMP: Date this dump completed: Sat Feb 3 02:06:22 2007
DUMP: Average transfer rate: 7672 kB/s
DUMP: DUMP IS DONE

Using the Restore command

For restoring a backup, another command is needed, aptly called restore.

To list the contents of a backup file, use this command:

restore -t -f /media/extdisk0/full-2007-02-01.dump 

To actually restore the data in the backup file do the following:

Create a fresh file system:

mkfs -t ext3 /dev/sda1 

Restore the data:

restore -r -f /media/extdisk0/full-2007-02-01.dump 

There are other options to restore, for example -C compares the contents of files from a backup to what is on the file system.

Resources

Contents: