5.4. Backing up ext2, ext3, or ext4 File Systems
This procedure describes how to back up the content of an ext4, ext3, or ext2 file system into a file.
Prerequisites
- If the system has been running for a long time, run the
e2fsckutility on the partitions before backup:e2fsck /dev/device
# e2fsck /dev/deviceCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Procedure 5.1. Backing up ext2, ext3, or ext4 File Systems
- Back up configuration information, including the content of the
/etc/fstabfile and the output of thefdisk -lcommand. This is useful for restoring the partitions.To capture this information, run thesosreportorsysreportutilities. For more information aboutsosreport, see the What is a sosreport and how to create one in Red Hat Enterprise Linux 4.6 and later? Kdowledgebase article. - Depending on the role of the partition:
- If the partition you are backing up is an operating system partition, boot your system into the rescue mode. See the Booting to Rescue Mode section of the System Administrator's Guide.
- When backing up a regular, data partition, unmount it.Although it is possible to back up a data partition while it is mounted, the results of backing up a mounted data partition can be unpredictable.If you need to back up a mounted file system using the
dumputility, do so when the file system is not under a heavy load. The more activity is happening on the file system when backing up, the higher the risk of backup corruption is.
- Use the
dumputility to back up the content of the partitions:dump -0uf backup-file /dev/device
# dump -0uf backup-file /dev/deviceCopy to Clipboard Copied! Toggle word wrap Toggle overflow Replace backup-file with a path to a file where you want the to store the backup. Replace device with the name of the ext4 partition you want to back up. Make sure that you are saving the backup to a directory mounted on a different partition than the partition you are backing up.Example 5.2. Backing up Multiple ext4 Partitions
To back up the content of the/dev/sda1,/dev/sda2, and/dev/sda3partitions into backup files stored in the/backup-files/directory, use the following commands:dump -0uf /backup-files/sda1.dump /dev/sda1 dump -0uf /backup-files/sda2.dump /dev/sda2 dump -0uf /backup-files/sda3.dump /dev/sda3
# dump -0uf /backup-files/sda1.dump /dev/sda1 # dump -0uf /backup-files/sda2.dump /dev/sda2 # dump -0uf /backup-files/sda3.dump /dev/sda3Copy to Clipboard Copied! Toggle word wrap Toggle overflow To do a remote backup, use thesshutility or configure a password-lesssshlogin. For more information onsshand password-less login, see the Using the ssh Utility and Using Key-based Authentication sections of the System Administrator's Guide.For example, when usingssh:Example 5.3. Performing a Remote Backup Using
sshdump -0u -f - /dev/device | ssh root@remoteserver.example.com dd of=backup-file
# dump -0u -f - /dev/device | ssh root@remoteserver.example.com dd of=backup-fileCopy to Clipboard Copied! Toggle word wrap Toggle overflow Note that if using standard redirection, you must pass the-foption separately.
Additional Resources Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
- For more information, see the dump(8) man page.