xfsrestore(8) | System Manager's Manual | xfsrestore(8) |
xfsrestore - XFS filesystem incremental restore utility
xfsrestore -h xfsrestore [ options ] -f source [ -f source ... ] dest xfsrestore [ options ] - dest xfsrestore -I [ subopt=value ... ]
xfsrestore restores filesystems from dumps produced by xfsdump(8). Two modes of operation are available: simple and cumulative.
The default is simple mode. xfsrestore populates the specified destination directory, dest, with the files contained in the dump media.
The -r option specifies the cumulative mode. Successive invocations of xfsrestore are used to apply a chronologically ordered sequence of delta dumps to a base (level 0) dump. The contents of the filesystem at the time each dump was produced is reproduced. This can involve adding, deleting, renaming, linking, and unlinking files and directories.
A delta dump is defined as either an incremental dump (xfsdump -l option with level > 0) or a resumed dump (xfsdump -R option). The deltas must be applied in the order they were produced. Each delta applied must have been produced with the previously applied delta as its base.
xfsrestore keeps state information in the xfsrestorehousekeepingdir, to inform subsequent invocations when used in cumulative mode, or in the event a restore is interrupted. To ensure that the state information can be processed, a compatible version of xfsrestore must be used for each subsequent invocation. Additionally, each invocation must run on a system of the same endianness and page size.
The options to xfsrestore are:
The first form of this option activates message logging across all restore subsystems. The second form allows the message logging level to be controlled on a per-subsystem basis. The two forms can be combined (see the example below). The argument subsys can take one of the following values: general, proc, drive, media, inventory, and tree.
For example, to restore the root filesystem with tracing
activated for all subsystems:
# xfsrestore -v trace -f /dev/tape /
To enable debug-level tracing for drive and media operations:
# xfsrestore -v drive=debug,media=debug -f /dev/tape /
To enable tracing for all subsystems, and debug level tracing for drive
operations only:
# xfsrestore -v trace,drive=debug -f /dev/tape /
The dumped filesystem is restored into the dest directory. There is no default; the dest must be specified.
A base (level 0) dump and an ordered set of delta dumps can be sequentially restored, each on top of the previous, to reproduce the contents of the original filesystem at the time the last delta was produced. The operator invokes xfsrestore once for each dump. The -r option must be specified. The dest directory must be the same for all invocations. Each invocation leaves a directory named xfsrestorehousekeeping in the dest directory (however, see the -a option above). This directory contains the state information that must be communicated between invocations. The operator must remove this directory after the last delta has been applied.
xfsrestore also generates a directory named orphanage in the dest directory. xfsrestore removes this directory after completing a simple restore. However, if orphanage is not empty, it is not removed. This can happen if files present on the dump media are not referenced by any of the restored directories. The orphanage has an entry for each such file. The entry name is the file's original inode number, a ".", and the file's generation count modulo 4096 (only the lower 12 bits of the generation count are used).
xfsrestore does not remove the orphanage after cumulative restores. Like the xfsrestorehousekeeping directory, the operator must remove it after applying all delta dumps.
A dump consists of one or more media files contained on one or more media objects. A media file contains all or a portion of the filesystem dump. Large filesystems are broken up into multiple media files to minimize the impact of media dropouts, and to accommodate media object boundaries (end-of-media).
A media object is any storage medium: a tape cartridge, a remote tape device (see rmt(8)), a regular file, or the standard input (currently other removable media drives are not supported). Tape cartridges can contain multiple media files, which are typically separated by (in tape parlance) file marks. If a dump spans multiple media objects, the restore must begin with the media object containing the first media file dumped. The operator is prompted when the next media object is needed.
Media objects can contain more than one dump. The operator can select the desired dump by specifying the dump label (-L option), or by specifying the dump UUID (-S option). If neither is specified, xfsrestore scans the entire media object, prompting the operator as each dump session is encountered.
The inventory display (-I option) is useful for identifying the media objects required. It is also useful for identifying a dump session. The session UUID can be copied from the inventory display to the -S option argument to unambiguously identify a dump session to be restored.
Dumps placed in regular files or the standard output do not span multiple media objects, nor do they contain multiple dumps.
Each dump session updates an inventory database in /var/lib/xfsdump/inventory. This database can be displayed by invoking xfsrestore with the -I option. The display uses tabbed indentation to present the inventory hierarchically. The first level is filesystem. The second level is session. The third level is media stream (currently only one stream is supported). The fourth level lists the media files sequentially composing the stream.
The following suboptions are available to filter the display.
The display may be restricted to media files contained in a specific media object.
Similarly, the display can be restricted to a specific filesystem.
More than one of these suboptions, separated by commas, may be specified at the same time to limit the display of the inventory to those dumps of interest. However, at most four suboptions can be specified at once: one to constrain the display hierarchy depth, one to constrain the dump level, one to constrain the media object, and one to constrain the filesystem.
For example, -I depth=1,mobjlabel="tape 1",mnt=host1:/test_mnt would display only the filesystem information (depth=1) for those filesystems that were mounted on host1:/test_mnt at the time of the dump, and only those filesystems dumped to the media object labeled "tape 1".
Dump records may be removed (pruned) from the inventory using the xfsinvutil program.
An additional media file is placed at the end of each dump stream.
This media file contains the inventory information for the current dump
session. If the online inventory files in /var/lib/xfsdump/inventory
are missing information for the current dump session, then the inventory
information in the media file is automatically added to the files in
/var/lib/xfsdump/inventory. If you wish to incorporate the inventory
information from the media file without restoring any data, you may do so
using the -t option:
# xfsrestore -t -f /dev/tape
This is useful to rebuild the inventory database if it is ever lost or
corrupted. The only caveat is that xfsrestore needs to read through
the entire dump in order to reach the inventory media file. This could
become time consuming for dump sessions with large media files.
xfsdump is tolerant of media errors, but cannot do error correction. If a media error occurs in the body of a media file, the filesystem file represented at that point is lost. The bad portion of the media is skipped, and the restoration resumes at the next filesystem file after the bad portion of the media.
If a media error occurs in the beginning of the media file, the entire media file is lost. For this reason, large dumps are broken into a number of reasonably sized media files. The restore resumes with the next media file.
When xfsdump dumps a filesystem with user quotas, it creates a file in the root of the dump called xfsdump_quotas. xfsrestore can restore this file like any other file included in the dump. This file can be processed by the restore command of xfs_quota(8) to reactivate the quotas. However, the xfsdump_quotas file contains information which may first require modification; specifically the filesystem name and the user ids. If you are restoring the quotas for the same users on the same filesystem from which the dump was taken, then no modification will be necessary. However, if you are restoring the dump to a different filesystem, you will need to:
- ensure the new filesystem is mounted with the quota option
- modify the xfsdump_quotas file to contain the new filesystem name
- ensure the uids in the xfsdump_quotas file are correct
Once the quota information has been verified, the restore command of xfs_quota (8) can be used to apply the quota limits to the filesystem.
Group and project quotas are handled in a similar fashion and will be restored in files called xfsdump_quotas_group and xfsdump_quotas_proj, respectively.
To restore the root filesystem from a locally mounted tape:
# xfsrestore -f /dev/tape /
To restore from a remote tape, specifying the dump session id:
# xfsrestore -L session_1 -f otherhost:/dev/tape /new
To restore the contents a of a dump to another subdirectory:
# xfsrestore -f /dev/tape /newdir
To copy the contents of a filesystem to another directory (see
xfsdump(8)):
# xfsdump -J - / | xfsrestore -J - /new
rmt(8), xfsdump(8), xfsinvutil(8), xfs_quota(8), attr_set(2).
The exit code is 0 on normal completion, and non-zero if an error occurred or the restore was terminated by the operator.
For all verbosity levels greater than 0 (silent) the final
line of the output shows the exit status of the restore. It is of the form:
xfsdump: Restore Status: code
Where code takes one of the following values: SUCCESS (normal
completion), INTERRUPT (interrupted), QUIT (media no longer
usable), INCOMPLETE (restore incomplete), FAULT (software
error), and ERROR (resource error). Every attempt will be made to
keep both the syntax and the semantics of this log message unchanged in
future versions of xfsrestore. However, it may be necessary to refine or
expand the set of exit codes, or their interpretation at some point in the
future.
Pathnames of restored non-directory files (relative to the dest directory) must be 1023 characters (MAXPATHLEN) or less. Longer pathnames are discarded and a warning message displayed.
There is no verify option to xfsrestore. This would allow the operator to compare a filesystem dump to an existing filesystem, without actually doing a restore.
The interactive commands (-i option) do not understand regular expressions.
When the minimal rmt option is specified, xfsrestore applies it to all remote tape sources. The same blocksize (specified by the -b option) is used for all these remote drives.
xfsrestore uses the alert program only when a media change is required.
Cumulative mode (-r option) requires that the operator invoke xfsrestore for the base and for each delta to be applied in sequence to the base. It would be better to allow the operator to identify the last delta in the sequence of interest, and let xfsrestore work backwards from that delta to identify and apply the preceding deltas and base dump, all in one invocation.