Data Loss Prevention   «Prev  Next»

Lesson 5 The dump backup command
Objective Use the dump Command to back up File Systems.

Linux dump Backup Command for Data Loss Protection

The `dump` command in Linux is a backup utility used to back up filesystems at a block level. In Red Hat Enterprise Linux (RHEL) 9.2, you can use the `dump` command to protect data by creating full or incremental backups of your filesystems. Here's how to use it for enabling data loss protection:
  1. Check Filesystem Compatibility

    The dump command works with ext2, ext3, and ext4 filesystems. Confirm the filesystem type of the partition you want to back up:

    df -T
  2. Install the dump Package

    If the dump utility is not installed, you can install it:

    sudo yum install dump
  3. Back Up a Filesystem

    To create a full backup of a filesystem, use:

    sudo dump -0uf /backup/location/backup_file.dump /dev/sdX
    • -0: Specifies a level-0 (full) backup.
    • -u: Updates the /etc/dumpdates file with the date and level of the dump.
    • -f: Specifies the backup file or device to store the dump.
    • /backup/location/backup_file.dump: Path to the backup file or tape device.
    • /dev/sdX: The device or partition to back up (e.g., /dev/sda1).
  4. Incremental Backups

    After a full backup, you can create incremental backups to save only the changes since the last backup:

    sudo dump -1uf /backup/location/incremental_backup.dump /dev/sdX
    • Specifies level-1 (incremental) backup. Incremental levels range from 1 (lowest) to 9 (highest).
  5. Verify the Backup

    To verify the integrity of the dump file:

    sudo restore -C -f /backup/location/backup_file.dump
  6. Restore from a Backup

    To restore from a backup file:

    1. Start the interactive restore mode:
      sudo restore -i -f /backup/location/backup_file.dump
    2. Use commands like ls to view contents and add to select files/directories for restoration.
    3. Use extract to restore selected files.

    Alternatively, to restore everything:

    sudo restore -r -f /backup/location/backup_file.dump
  7. Automate Backups

    Create a cron job for regular backups:

    crontab -e

    Add an entry for daily backups (adjust time and paths as needed):

    0 2 * * * /sbin/dump -0uf /backup/location/daily_backup.dump /dev/sdX
  8. Secure the Backup

    Ensure the backup file is securely stored. Options include:

    • Encrypting the backup file with tools like gpg.
    • Copying the backup file to a remote server using scp or rsync.
Example Scenario
To back up the `/home` directory mounted on `/dev/sda1`:
sudo dump -0uf /backup/home_backup.dump /dev/sda1

To restore it:
sudo restore -r -f /backup/home_backup.dump

Best Practices
This approach ensures your data is protected from potential loss on RHEL 9.2 systems.

Red Hat Enterprise Linux 9 Administration

Red Hat Backup Options

The dump command offers a more extensive set of backup options by allowing fine-grained incremental as well as full dumps to be performed. System administrators responsible for maintaining backups of large quantities of moderately volatile data will find this extremely useful. With incremental dumps, time-intensive full backups can be performed less often with shorter incremental dumps used to "fill in the blanks."
The dump command:
  1. Backs up files or directories
  2. Supports backup levels from 0 (full) to 9
  3. Is available as a Red Hat Linux RPM[1]

The following series of images illustrates several examples:

dump backup command
1) The -u option will update the file /etc/dumpdates, which will record dump information for future use. This command performs a full backup of the /home file system onto the tape device nrst1 and record the dump information in /etc/dumpdates as specified by the -u option.
1)
dump -0u -f /dev/nrst1 /home

The -u option will update the file /etc/dumpdates, which will record dump information for future use. This command performs a full backup of the /home file system onto the tape device nrst1 and records the dump information in /etc/dumpdates as specified by the -u option.

2) This use of the -u option performs an incremental update of all files that have been changed or added since the last backup of level 4 or lower, as recorded in the /etc/dumpates file.
2)
dump -4u -f /dev/nrst1 /home
This use of the -u option performs an incremental update of all files that have been changed or added since the last backup of level 4 or lower, as recorded in the
/etc/dumpates
file.

Backing Up Files with dump

The dump command was historically one of the most commonly used tools for performing backups on UNIX systems. This command traces its history back to the early days of UNIX and thus is a standard part of nearly every version of UNIX. Likewise, the dump package is included in Fedora and Red Hat Enterprise Linux. If it was not installed by default when you first set up your Linux system, you can install it from the dump RPM file located on the Fedora installation DVD.
Note: The dump and restore commands, while widely used for many years, are not considered to be particularly reliable or robust backup and restore tools these days. Also, they can be used only on ext2 and ext3 file system types and it is safest to use dump and restore on unmounted file systems. Descriptions of those tools are included here to support those with legacy backup media and automated scripts that still use those commands. The dump package actually consists of several commands. You can read online man pages for more information about them. Table 4-5 provides a short description of the programs.
Table 4-5: Programs in the dump Package
Command Description
dump Creates backup archives of whole disk partitions or selected directories.
restore Can be used to restore an entire archive or individual files from an archive to the hard drive.
rmt A program used by the dump and restore commands to copy files across the network. You should never need to use this command directly.

Linux Administration

Creating backup with dump

When making a file system backup using the dump command, you must supply parameters specifying the dump level, the backup media, and the file system to back up. You can also supply optional parameters to specify the size of the backup media, the method for requesting the next tape, and the recording of file system dump times and status. The first parameter to dump is always a list of single-letter option codes. This is followed by a space-separated list of any arguments needed by those options. The arguments appear in the same order as the options that require them. The final parameter is always the file system or directory being backed up.
# dump options arguments filesystem

Scheduling dumps
The appropriate dump schedule depends on whether you wish to reduce the size of the dumps or the number of restores necessary to recover. To decrease the size of the incremental dumps, use a dump schedule in which the level increases every day. If you wish to minimize the number of restores needed to recover a file system, you should use a dump schedule in which the dump level decreases every day. For example, a dump schedule of zero on Sunday, six on Tuesday, four on Thursday, and two on Saturday would be an appropriate schedule for a stable system with little alteration to the files. In this scenario, only two restores would be needed to reinstate the system: a full restore layered with the incremental restore. The next lesson examines the restore command.

[1]RPM: An acronym for Red Hat Package Manager, an RPM is a group of files stored in a single portable file.

SEMrush Software 5 SEMrush Banner 5