On a Linux operating system environment, mastering how to create and restore backups is a very important skill set. It is easier for well-versed Linux user to attain their data backup goals from the terminal environment without the need for a GUI-oriented application package.
The Linux dump utility is effective in creating filesystem backups on an availed storage device. However, the filesystem supported by this backup utility disregards the likes of ReiserFS and FAT.
[ You might also like: How to Clone and Restore Linux Partition Using dd Command ]
The dump command only supports ext4, ext3, and ext2 filesystem and incremental backups. Under incremental backup support, a Linux user can flexibly execute their backup operations on daily, weekly, or monthly time frames.
It makes it easy to decide when and how you want your backups done. You get to decide which files should be involved in the scheduled backup process. Therefore, a Linux user can only focus on backing up files with significant changes or the ones that were recently added to the targeted filesystem.
How to Install Dump Utility in Linux
If you do not have the dump utility installed on your Linux machine, you can install it by executing one of the following installation commands in regards to the Linux operating system distribution you are using.
$ sudo apt-get install dump [On Debian, Ubuntu and Mint] $ sudo yum install dump [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux] $ sudo emerge -a sys-apps/dump [On Gentoo Linux] $ sudo pacman -S dump [On Arch Linux] $ sudo zypper install dump [On OpenSUSE]
Linux Dump Command Usage
Once you run the dump backup utility, it first examines your existing Linux filesystem files and points out the ones that are worthy of any backup effort. The dump command needs several parameters for it to execute successfully:
- The targeted dump level.
- The media to host the created filesystem backup.
- The filesystem to backup.
The dump command also accommodates optional parameters pointing to:
- Specific backup media size.
- Next tape request method.
- Times and status of filesystem dump recording.
A typical dump command string adheres to the following syntax:
$ sudo dump options arguments filesystem
The dump command options:
- 0-9 – This range signifies available dump levels. 0 caters for full filesystem backup while a higher number like 9 only prioritizes the backup of modified filesystem files.
- -B records – Highlights how many dump records should exist in a single volume.
- -b kbperdump – Highlights the number of kilobytes within a single dumb record.
- -h level – With this option, a nodump attribute is associated with your backup files.
- -f file – Points to a file or device name that will accommodate the created dump.
- -d destiny – Defines the needed tape density.
- -n – Use to alert operator group users when something like a tape change is required by the dump operation.
- -s feet: Specifies the dump tape length in feet.
- -u – Creates a record of all successful backups under the file /etc/dumpdates.
- -t date – Specifies the date and time values associated with incremental backups.
- -W – This option references the /etc/fstab and /etc/dumpdates files and highlights filesystem files that need backup.
- -w – Goes hand in hand with the W option and highlights specific/individual files that need backup.
How to Backup Linux System using Dump Command
To determine the files that need backup on your Linux system, you will run a command similar to the following:
$ dump -W or $ dump -Ww
To back up the above filesystem (/dev/sda5) to an external device like /dev/sdb5 (identified by running the command sudo fdisk -l
), I would implement a dump command similar to the following:
$ sudo dump 0uaf /dev/sdb5 /dev/sda5
The dump command has the dump option 0 since it’s a first-time backup attempt.
If you need your backup compressed, you would run the above command in the following manner:
$ sudo dump 0ufz /dev/sdb5 /dev/sda5
The created backup will be compressed with the z library. The dump backup command updates the system user as it continues to execute:
Backup Linux Home Directory
To back up the files from a specific filesystem directory like your Home directory:
$ sudo dump 0ufz /dev/sdb5 /home
To back up files to a remote machine named linuxshelltips or identified by an IP address and with the tape device named /dev/sdb5, we will use the rdump command.
$ sudo rdump 0uf linuxshelltips:/dev/sdb5 /home
Backing Up Data to a Regular File
Supposing we want to back up the home directory to an existing regular file called 10g.img, we would implement the needed command in the following manner:
$ sudo dump 0f /media/dnyce/4E6A2E2E6A2E136F/10g.img /home
To create such a writable image file to hold your backup data, run the following command. Also, specify the size of this writable image file.
$ dd if=/dev/zero of=10g.img bs=1 count=0 seek=10G
Afterward, check the created backup file:
$ file 10g.img
The created .img
file backup can now be written to a disk device of your choice with this command:
$ sudo dd if=10g.img of=/dev/sdb5 bs=1M
How to Restore Linux System using Dump Command
To fully restore the above-created backup, we would run a command similar to the following:
$ sudo restore rf /dev/sdb5
The restored files will be written on the current directory path of the active Linux system user.
To restore filesystem backups from a remote machine we will use the rrestore command:
$ sudo rrestore tf linuxshelltips:/dev/sdb5
With the dump command, you can easily achieve full and incremental backups of your Linux filesystem files. The restore command reverses or does the opposite of the dump command to successfully re-instate your filesystem backups.
To learn more about these two commands and their usage, run:
$ man dump $ man restore
A little scary.
The consequences of inadvertently swapping sdb5 and sda5 could
be catastrophic.
Dump can write to a regular file which is probably a bit safer at least while testing.
eg:
Also, disk devices are often read-only for group ‘disk‘ so that running a dump as an unprivileged user in-group ‘disk‘ is another possible precaution.
eg for user backup:disk something like: