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 e2fsck utility on the partitions before backup:
    # e2fsck /dev/device

Procedure 5.1. Backing up ext2, ext3, or ext4 File Systems

  1. Back up configuration information, including the content of the /etc/fstab file and the output of the fdisk -l command. This is useful for restoring the partitions.
    To capture this information, run the sosreport or sysreport utilities. For more information about sosreport, see the What is a sosreport and how to create one in Red Hat Enterprise Linux 4.6 and later? Kdowledgebase article.
  2. 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 dump utility, 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.
  3. Use the dump utility to back up the content of the partitions:
    # dump -0uf backup-file /dev/device
    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/sda3 partitions 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
    To do a remote backup, use the ssh utility or configure a password-less ssh login. For more information on ssh and password-less login, see the Using the ssh Utility and Using Key-based Authentication sections of the System Administrator's Guide.
    For example, when using ssh:

    Example 5.3. Performing a Remote Backup Using ssh

    # dump -0u -f - /dev/device | ssh root@remoteserver.example.com dd of=backup-file
    Note that if using standard redirection, you must pass the -f option separately.

Additional Resources

  • For more information, see the dump(8) man page.
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.