0% found this document useful (0 votes)
9 views

How To Backup and Restore A Whole Red Hat Enterprise Linux System With The Dump - Restore Commands

The document describes how to backup and restore a whole Red Hat Enterprise Linux system using the dump and restore commands. It provides step-by-step instructions on using dump to backup partitions to another disk, simulating a disk failure, rebuilding partitions and filesystems, and restoring from the backup using restore.

Uploaded by

Fresh Juice
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

How To Backup and Restore A Whole Red Hat Enterprise Linux System With The Dump - Restore Commands

The document describes how to backup and restore a whole Red Hat Enterprise Linux system using the dump and restore commands. It provides step-by-step instructions on using dump to backup partitions to another disk, simulating a disk failure, rebuilding partitions and filesystems, and restoring from the backup using restore.

Uploaded by

Fresh Juice
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Subscriptions Downloads Containers Support Cases

Products & Services Knowledgebase How to backup and restore a whole Red Hat Enterprise Linux system with the
dump/restore commands?

How to backup and restore a whole Red Hat


Enterprise Linux system with the dump/restore
commands?
$ SOLUTION VERIFIED - Updated November 18 2020 at 1:31 PM - English

Environment
Red Hat Enterprise Linux 4
Red Hat Enterprise Linux 5
Red Hat Enterprise Linux 6
Red Hat Enterprise Linux 7
ext2, ext3 or ext4 filesystem
dump and restore

Issue
How to backup and restore a whole Red Hat Enterprise Linux system with the dump/restore
commands?
Need to migrate, upgrade, or perform disaster recovery on the OS, how to create a backup
image?
Is it possible to take complete back of OS+ application in RHEL like ignite or system state
back up?

The following information has been provided by Red Hat, but is outside the scope of the
posted Service Level Agreements and support procedures (Production Support - Red
Hat Customer Portal). The information is provided as-is and any configuration settings
or installed applications made from the information in this article could make the
Operating System unsupported by Red Hat Global Support Services. The intent of this
article is to provide information to accomplish the system's needs. Use of the
information in this article at the user's own risk.
Resolution
1. Introduction
This article shows a test in which a whole Red Hat Enterprise Linux 5.2 system is backed-up to
another disk partition, the files system is then destroyed using fdisk (to simulate a disk failure),
and finally the system is restored successfully. All the steps can also be used for Red Hat
Enterprise Linux 4.

NOTE 1: Since there are different kinds of storage, we could not make detailed test on them, and
also consider that any mistake will destroy the system and difficult to recover, so we STRONGLY
RECOMMEND to test all the steps on a test machine.

NOTE 2:Since there is now a GPT partitions you may use parted instead of fdisk.

NOTE 3: Red Hat provides ReaR as an emergency disaster recovery tool. More information on
this can be found at What is Relax and Recover(ReaR) and how can I use it for disaster recovery?
and CHAPTER 26. RELAX-AND-RECOVER (REAR)

2. Configuration Procedure
Backup Using Dump
1. All data must be backed up before attempting any kind of restore operation. Data
backups should be made on a regular basis. In addition to data, there is configuration
information that should be saved, including "/etc/fstab" and the output of "fdisk -l". Running
a sosreport/sysreport will capture this information and is strongly recommended.

# cat /etc/fstab
LABEL=/ / ext3 defaults 1 1
LABEL=/boot1 /boot ext3 defaults 1 2
LABEL=/data /data ext3 defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
LABEL=SWAP-sda5 swap swap defaults 0 0
/dev/sda6 /backup-files ext3 defaults 0 0

# fdisk -l
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1925 15358140 83 Linux
/dev/sda3 1926 3200 10241437+ 83 Linux
/dev/sda4 3201 4864 13366080 5 Extended
/dev/sda5 3201 3391 1534176 82 Linux swap / Solaris
/dev/sda6 3392 4864 11831841 83 Linux
In this example, we will use the /dev/sda6 partition to save backup files, and we assume that
/dev/sda6 is mounted on /backup-files.
2. Bootup your system into Single User Mode

3. Use "dump" to backup the contents of the partitions:

Notes

If the system has been running for a long time, it is advisable to run e2fsck on the
partitions before backup.
dump should(may) not be used at heavily loaded and mounted filesystem as it could
backup corrupted version of files. This problem has been mentioned on
dump.sourceforge.net and Red Hat Manual

# dump -0uf /backup-files/sda1.dump /dev/sda1


# dump -0uf /backup-files/sda2.dump /dev/sda2
# dump -0uf /backup-files/sda3.dump /dev/sda3

If you want to do a remote backup, you can use both ssh or configure a non-password login.
For information on how to configure ssh for a non-password login, please see How do you
set-up SSH with DSA public key authentication?
Note: If using standard redirection, the '-f' option must be passed separately.

# dump -0u -f - /dev/sda1 | ssh [email protected] dd of=/tmp/sda1.dump

4. We then simulate a disk failure by using fdisk to delete the partitions that have been backed
up.

Notice: DO NOT delete /dev/sda6 because it saves our backup files. In general, backup
files should of course be stored on in a different location.

Restoring the Backed-Up Data


1. Bootup your system into Rescue Mode

2. Rebuild sda1/sda2/sda3/sda4/sda5 by using the fdisk command

Notice: When rebuild all the partitions, please use the same "Start" and "End" number as
before.

3. format sda1/sda2/sda3/sda5 by using the mkfs command, as shown below.

Notice: DO NOT format /dev/sda6 because it saves backup files.


# mkfs.ext3 /dev/sda1
# mkfs.ext3 /dev/sda2
# mkfs.ext3 /dev/sda3

4. Re-label all the partitions so they match how they were before. This step is important for
the restore to work.

# e2label /dev/sda1 /boot1


# e2label /dev/sda2 /
# e2label /dev/sda3 /data
# mkswap -L SWAP-sda5 /dev/sda5

5. Prepare the working directories

# mkdir /mnt/sda1
# mount -t ext3 /dev/sda1 /mnt/sda1
# mkdir /mnt/sda2
# mount -t ext3 /dev/sda2 /mnt/sda2
# mkdir /mnt/sda3
# mount -t ext3 /dev/sda3 /mnt/sda3
# mkdir /backup-files
# mount -t ext3 /dev/sda6 /backup-files

6. Restore the data

# cd /mnt/sda1
# restore -rf /backup-files/sda1.dump
# cd /mnt/sda2
# restore -rf /backup-files/sda2.dump
# cd /mnt/sda3
# restore -rf /backup-files/sda3.dump

If want remote restore, you can use both ssh or rsh, maybe you need to configure a none-
password login, the following is examples:

login into 192.168.1.87, and restore sda1 from local sda1.dump file:

# ssh 192.168.1.87 "cd /mnt/sda1 && cat /backup-files/sda1.dump | restore -rf -"

login into 192.168.1.87, and restore sda1 from a remote 192.168.1.124 sda1.dump file:

# ssh 192.168.1.87 "cd /mnt/sda1 && RSH=/usr/bin/ssh restore -r -f


192.168.1.124:/tmp/sda1.dump"

7. Reboot
3. Other Notices
1. dump/restore command can only be used for ext2/ext3/ext4 partitions, some IA64 system
has a boot partition in vfat format, tar command can be used to backup a vfat partition.

The ext4 filesystem is supported by dump/restore command only in Red Hat


Enterprise Linux 6:
Is dump available for ext4 file systems on RHEL 6?

Red Hat Enterprise Linux 5 dump program does not support the ext4 file system.

2. The MBR is not backup for it is not belong to any partition! So, if you backup your system to
another disk, the system is not able to boot up. Please run grub-install in rescue mode first.

3. Some system will setting immunity flag on some important files which means these files
could not be deleted/modified/overwrited even by root user, so restore will failed to
overwrite these file and output "Permission Denied" error. In this situation, before restore
the system, please find out the files have immunity flag with lsattr command, and remove
the immunity flag with "chattr -i" command.

4. You can backup your data to tape device, another hard disk or another disk partition, just
change the dump file name to tape device like following:

# dump -0uf /dev/st0 /dev/sda1

5. When use tape device, you need mt command to control forward/backward of tape, please
take care of the operation order to make sure the right data is restored into a right partition.

6. There are some factors can influence the backup/restore, such as the tape device' driver,
type(rewind/non-rewind), and the size of data block, so I suggest you to use the same tape
device in backup and restore.

7. In the test of this article selinux is enabled, and some files' selinux property have been
modified, but seems everything can be restored correctly.

8. At last, only one dump/restore can not ensure the data security of your system, the real data
security need some detail security policy and backup policy.

9. If the root partition is a lvm partition. When restoring the root partition, you should run in
the rescue mode.
and do the things as follows.
# vgscan
# vgchange -ay VolGroup
# mount /dev/VolGroup/lv_root /mnt/sysimage
# cd /mnt/sysimage
# restore -rf <the dump file of root partition>

10. For how to backup and restore partition table, please refer to How can I backup and restore
partition table?

Product(s) Red Hat Enterprise Linux Component dump Category Learn more

Tags backup ext2 ext3 ext4 labs_rbra rhel rhel_4 rhel_5 rhel_6 rhel_7

This solution is part of Red Hat’s fast-track publication program, providing a huge library of
solutions that Red Hat engineers have created while supporting our customers. To give you the
knowledge you need the instant it becomes available, these articles may be presented in a raw
and unedited form.

People who viewed this solution also viewed

Backup and Restore Backup and Restore How to restore Red Hat
Procedures for Database in Satellite 5.6 from
Certificate System 7.3 CloudForms backup.

Solution - 5 thg 6, 2010 Solution - 14 thg 6, 2022 Solution - 8 thg 3, 2016

14 Comments

Nedunchelian Kulendran 13 March 2013 6:12 PM


NK How backup through network in system in single user mode?
NEWBIE
Network not availabl runlevel 1 (single user mode).
7 Points
# dump -0uf - /dev/sda1 | ssh [email protected] dd of=/tmp/sda1.dump

≤ Reply

Bruce Shei 14 March 2013 8:40 PM


BS Just do '/sbin/service network restart'.
ACTIVE
CONTRIBUTOR ≤ Reply
177 Points

Bruce Shei 14 March 2013 8:42 PM


BS Unless you have to restore from several level backups, you don't need "r" in restore; i.e., 'restore xf
ACTIVE
-' works as well.
CONTRIBUTOR

177 Points ≤ Reply

Santosh Gupta 20 April 2014 2:04 PM


SG A restoresymtable file is created after restoring the dump file.
COMMUNITY
should it be deleted...?? what is it's impact...???
MEMBER

25 Points ≤ Reply

[email protected] 13 March 2015 1:23 AM


JE Currently working on transferring this article to the Storage Admin Guide. Will provide a link once I
RED HAT am completed.
COMMUNITY
MEMBER
≤ Reply
25 Points

Chris Brown 16 May 2019 5:38 PM


CB Just curious if this article is still relevant, is this now in the storage admin guide?
NEWBIE
≤ Reply
5 Points

Amel Hodzic 4 August 2015 1:12 PM

It might be useful to create a link pointing to the XFS-related methods, as that is the default
filesystem in RHEL7.
PRO
≤ Reply
653
Points

Mateusz Bisikiewicz 20 August 2015 8:06 AM


MB How to restore partition encrypted with LUKS ?
NEWBIE
≤ Reply
5 Points

Karthik Subbaraj 17 February 2016 2:17 AM


KS This is a really a good document to refer for OS backup. How ever if we can also have table
NEWBIE
differentiating on "backsnap" & "dump/restore" process. this will help one to choose which one is
7 Points
correct suitable for the existing environment.

≤ Reply

Robert Johnston 21 June 2016 12:26 PM


RJ Can someone PLEASE fix the grammar in this article? It really tanks in Section 3. Example:
NEWBIE
"3.Some system will setting immunity flag on some important files which means these files could
18 Points
not be deleted/modified/overwrited even by root user, so restore will failed to overwrite these file
and output "Permission Denied" error. In this situation, before restore the system, please find out
the files have immunity flag with lsattr command, and remove the immunity flag with "chattr -i"
command."

≤ Reply

Jonathan Hebert 16 September 2018 3:35 PM

Is it possible/advisable to perform the dump without having to boot to single user mode?
NEWBIE
≤ Reply
5 Points

AMIT SHARMA - 17 September 2018 7:07 AM


A- if its in lvm we need follow to abve stups .......?
COMMUNITY
MEMBER ≤ Reply
50 Points
Santos Venter Chibenga 9 February 2020 7:13 PM

How about the use of DD command?


NEWBIE
≤ Reply
7 Points

Michael Quick 23 September 2022 3:37 AM

Man this did not work... my system has sda1 (/boot) and sda2 (LVMs) and it got back super block
NEWBIE
magic number and there was no way to fix it because writing it with fsck -b xxxxxx tried to read
12 Points
/etc/fstab but that didn't exist because I was using the rescue media. I'm curious if this works on
LVMs ?

≤ Reply

Copyright © 2023 Red Hat, Inc.

You might also like