Restoring an XFS File System From Backup
Use the xfsrestore command to find out information about the
backups you have made of an XFS file system or to restore data from a backup.
- Review all available backups by using the
xfsrestore -Icommand to view the backup inventory.Thexfsrestore -Icommand displays information about the available backups, including the session ID and session label. - Restore a full backup to a target location by using the
xfsrestorecommand and specifying either the session ID, by using the-Soption, or session label, by using the-Loption, for the backup.For example, to restore an XFS file system from a level 0 backup by specifying the session ID, you would use the following command:
sudo xfsrestore -f /dev/st0 -S c76b3156-c37c-5b6e-7564-a0963ff8ca8f /mnt - Cumulatively restore all data starting from a level 0 backup and working
through all available incremental backups, by using the
xfsrestore -rcommand.Specify the
-roption to cumulatively recover all the data from a level 0 backup, and higher-level backups that are based on that backup:sudo xfsrestore -r -f /dev/st0 -v silent /mntThis command searches for backups in the archive, based on the level 0 backup, and then prompts you to select whether you want to restore each backup, in turn. After restoring the selected backup, the command exits. Note that you must run this command several times, first selecting to restore the level 0 backup, and then later higher-level backups, including the most recent backup that you require to restore the file system data.
Note:
After completing a cumulative restoration of an XFS file system, delete the
housekeepingdirectory that thexfsrestorecommand creates in the destination directory. - Extract a single file or subdirectory from a backup by using the
xfsrestore -scommand.For example, to recover the contents of
/var/logfrom the backup into the target directory at/tmp/restored_logs, you can do:mkdir /tmp/restored_logs sudo xfsrestore -s var/log -f /backups/root.0.xfsdump /tmp/restored_logs/ - Use the
xfsrestore -icommand to run the restore command in interactive mode.The interactive restore tool provides subcommands that can be run within the restore shell to navigate around the dump session and to add or remove items that you want to finally extract to the provided location:cd: change directory within the dump session.ls: list the contents of the current directory in the dump session.add: add a file or directory from the current directory to the queue of items to extract.delete: delete a file or directory from the queue of items to extract.extract: extract the items in the queue to the target location.
For example to enter interactive mode to recover files from a dump file at
/backups/boot.0.xfsdumpand to extract to the target location at/tmp/restore_boot, run:sudo xfsrestore -i -f /backups/boot.0.xfsdump /tmp/restore_boot