Este contenido no está disponible en el idioma seleccionado.
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
orparted
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 thefdisk
utility when backing up.For more information on modifying partitions, see Chapter 13, Partitions - Use the
mkfs
utility to format the destination partition:#
mkfs.ext4 /dev/device
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:#
e2label /dev/device label
- Create temporary mount points and mount the partitions on them:
#
mkdir /mnt/device
#
mount -t ext4 /dev/device /mnt/device
- Restore the data from backup on the mounted partition:
#
cd /mnt/device
#
restore -rf device-backup-file
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 thessh
utility. For more information onssh
, 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-lessssh
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:
#
ssh remote-address "cd /mnt/device && cat backup-file | /usr/sbin/restore -r -f -"
- To restore a partition on a remote machine from a backup file stored on a different remote machine:
#
ssh remote-machine-1 "cd /mnt/device && RSH=/usr/bin/ssh /usr/sbin/restore -rf remote-machine-2:backup-file"
- Reboot:
#
systemctl 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:
#
mkfs.ext4 /dev/sda1
#
mkfs.ext4 /dev/sda2
#
mkfs.ext4 /dev/sda3
- Re-label all the partitions so they match the
/etc/fstab
file:#
e2label /dev/sda1 Boot1
#
e2label /dev/sda2 Root
#
e2label /dev/sda3 Data
- Prepare the working directories.Mount the new partitions:
#
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
Mount the partition that contains backup files:#
mkdir /backup-files
#
mount -t ext4 /dev/sda6 /backup-files
- Restore the data from backup to the mounted partitions:
#
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
- Reboot:
#
systemctl reboot
Additional Resources
- For more information, see the restore(8) man page.