5.5. Restoring ext2, ext3, or ext4 File Systems This procedure describes how to restore an ext4, ext3, or ext2 file system from a file backup. Prerequisites You need a backup of partitions and their metadata, as described in Section 5.4, "Backing up ext2, ext3, or ext4 File Systems" . Procedure 5.2. Restoring ext2, ext3, or ext4 File Systems If you are restoring an operating system partition, boot your system into Rescue Mode. See the Booting to Rescue Mode section of the System Administrator's Guide . This step is not required for ordinary data partitions. Rebuild the partitions you want to restore by using the fdisk or parted utilites. If the partitions no longer exist, recreate them. The new partitions must be large enough to contain the restored data. It is important to get the start and end numbers right; these are the starting and ending sector numbers of the partitions obtained from the fdisk utility when backing up. For more information on modifying partitions, see Chapter 13, Partitions Use the mkfs utility to format the destination partition: Important Do not format the partition that stores your backup files. If you created new partitions, re-label all the partitions so they match their entries in the /etc/fstab file: Create temporary mount points and mount the partitions on them: Restore the data from backup on the mounted partition: If you want to restore on a remote machine or restore from a backup file that is stored on a remote host, you can use the ssh utility. For more information on ssh , see the Using the ssh Utility section of the System Administrator's Guide . Note that you need to configure a password-less login for the following commands. For more information on setting up a password-less ssh login, see the Using Key-based Authentication section of the System Administrator's Guide . To restore a partition on a remote machine from a backup file stored on the same machine: To restore a partition on a remote machine from a backup file stored on a different remote machine: Reboot: Example 5.4. Restoring Multiple ext4 Partitions To restore the /dev/sda1 , /dev/sda2 , and /dev/sda3 partitions from Example 5.2, "Backing up Multiple ext4 Partitions" : Rebuild partitions you want to restore by using the fdisk command. Format the destination partitions: Re-label all the partitions so they match the /etc/fstab file: Prepare the working directories. Mount the new partitions: Mount the partition that contains backup files: Restore the data from backup to the mounted partitions: Reboot: Additional Resources For more information, see the restore (8) man page.

Commands:
mkfs.ext4 /dev/ device
e2label /dev/ device label
mkdir /mnt/ device # mount -t ext4 /dev/ device /mnt/ device
cd /mnt/ device # restore -rf device-backup-file
ssh remote-address "cd /mnt/ device && cat backup-file | /usr/sbin/restore -r -f -"
ssh remote-machine-1 "cd /mnt/ device && RSH=/usr/bin/ssh /usr/sbin/restore -rf remote-machine-2 : backup-file "
systemctl reboot
mkfs.ext4 /dev/sda1 # mkfs.ext4 /dev/sda2 # mkfs.ext4 /dev/sda3
e2label /dev/sda1 Boot1 # e2label /dev/sda2 Root # e2label /dev/sda3 Data
mkdir /mnt/sda1 # mount -t ext4 /dev/sda1 /mnt/sda1 # mkdir /mnt/sda2 # mount -t ext4 /dev/sda2 /mnt/sda2 # mkdir /mnt/sda3 # mount -t ext4 /dev/sda3 /mnt/sda3
mkdir /backup-files # mount -t ext4 /dev/sda6 /backup-files
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
systemctl reboot