Chapter 6. Backup and Recovery Procedures

This section discusses the following:

For more information, see the xfsdump(8) and xfsrestore(8) man pages.

Features of xfsdump and xfsrestore

The xfsdump and xfsrestore utilities fully support XFS filesystems. With xfsdump and xfsrestore, you can back up and restore data using local or remote drives. You can back up filesystems, directories, and individual files, and then restore them independently of how they were backed up. xfsdump also allows you to back up “live” (mounted, in-use) filesystems.

With xfsdump and xfsrestore, you can recover from intentional or accidental interruptions--this means you can interrupt a dump or restore at any time, and then resume it whenever desired. xfsdump and xfsrestore support incremental dumps, and multiple dumps can be placed on a single media object.

xfsdump and xfsrestore support the following:

  • XFS features including 64-bit inode numbers, file lengths, and holes

  • Multiple media types (disk and various kinds of tape )

  • File types:

    Regular
    Directory
    Symbolic link
    Block and character special
    FIFO
    socket

xfsdump and xfsrestore retain hard links. xfsdump does not affect the state of the filesystem being dumped (for example, access times are retained). xfsrestore detects and bypasses media errors and recovers rapidly after encountering them. xfsdump does not cross mount points, local or remote.

xfsdump optionally prompts for additional media when the end of the current media is reached. Operator estimates of media capacity are not required and xfsdump also supports automated backups. xfsdump maintains an extensive online inventory of all dumps performed. Inventory contents can be viewed through various filters to quickly locate specific dump information. xfsrestore supports interactive operation, allowing selection of individual files or directories for recovery. It also permits selection from among backups performed at different times when multiple dumps are available. Dump contents may also be viewed noninteractively.


Note: If you are using disk quotas on XFS filesystems, see Chapter 5, “Disk Quotas”.


Media Layout for xfsdump

The following section introduces some terminology and then describes the way xfsdump formats data on the storage media for use by xfsrestore.

While xfsdump and xfsrestore are often used with tape media, the utilities actually support multiple kinds of media, so in the following discussions, the term media object is used to refer to the media in a generic fashion. The term dump refers to the result of a single use of the xfsdump command to output data files to the selected media objects. An instance of the use of xfsdump is referred to as a dump session.

The dump session sends a single dump stream to the media objects. The dump stream may contain as little as a single file or as much as an entire filesystem. The dump stream is composed of dump objects , which are:

  • One or more data segments

  • An optional dump inventory

  • A stream terminator

The data segment contains the actual data, the dump inventory contains a list of the dump objects in the dump, and the stream terminator marks the end of the dump stream. When a dump stream is composed of multiple dump objects, each object is contained in a media file. Some output devices, for example standard output, do not support the concept of media files--the dump stream is only the data.

Possible xfsdump Layouts

The simplest dump, for example the dump of a small amount of data to a single tape, produces a data segment and a stream terminator as the only dump objects. If the optional inventory object is added, you have a dump like that illustrated in Figure 6-1. (In the data layout diagrams in this section, the optional inventory object is always included.)

Figure 6-1. Single Dump on Single Media Object

Single Dump on Single Media Object

You can also dump data streams that are larger than a single media object. The data stream can be broken between any two media files including data segment boundaries. (The inventory is never broken into segments.) In addition, if you specify multiple drives, the dump is automatically broken into multiple streams. The xfsdump utility prompts for a new media object when the end of the current media object is reached.

Figure 6-2 illustrates the data layout of a single dump session that requires two media objects on each of two devices.

Figure 6-2. Single Dump on Multiple Media Objects

Single Dump on Multiple Media Objects

The xfsdump utility also accommodates multiple dumps on a single media object. When dumping to tape, for example, the tape is automatically advanced past the existing dump sessions and the existing stream terminator is erased. The new dump data is then written, followed by the new stream terminator. (For drives that do not permit termination to operate in this way, other means are used to achieve the same effective result.)

Figure 6-3 illustrates the layout of media files for two dumps on a single media object.

Figure 6-4 illustrates a case in which multiple dumps use multiple media objects. If media files already exist on the additional media objects, the xfsdump utility finds the existing stream terminator, erases it, and begins writing the new dump data stream.

Figure 6-3. Multiple Dumps on Single Media Object

Multiple Dumps on Single Media Object

Figure 6-4. Multiple Dumps on Multiple Media Objects

Multiple Dumps on Multiple Media Objects

Saving Data with xfsdump

This section discusses the following:

xfsdump Syntax

You must be the superuser to use xfsdump. To display a summary of xfsdump syntax, use the -h option:

# xfsdump -h 
xfsdump: version X.X 
xfsdump: usage: xfsdump [ -b <blocksize> (with minimal rmt option) ]
                        [ -c <media change alert program> ]
                        [ -f <destination> ... ]
                        [ -h (help) ]
                        [ -l <level> ]
                        [ -m <force usage of minimal rmt> ]
                        [ -o <overwrite tape > ]
                        [ -p <seconds between progress reports> ]
                        [ -s <subtree> ... ]
                        [ -v <verbosity {silent, verbose, trace}> ]
                        [ -A (don't dump extended file attributes) ]
                        [ -B <base dump session id> ]
                        [ -E (pre-erase media) ]
                        [ -F (don't prompt) ]
                        [ -I (display dump inventory) ]
                        [ -J (inhibit inventory update) ]
                        [ -L <session label> ]
                        [ -M <media label> ... ]
                        [ -O <options file> ]
                        [ -R (resume) ]
                        [ -T (don't timeout dialogs) ]
                        [ -Y <I/O buffer ring length> ]
                        [ - (stdout) ]
                        [ <source (mntpnt|device)> ]

Specifying Local Media

You can use xfsdump to back up data to various media. For example, you can dump data to a tape or hard disk. The drive containing the media object may be connected to the local system or accessible over the network.

Following is an example of a level-0 dump to a local tape drive.


Note: The dump level does not need to be specified for a level-0 dump. For a discussion of dump levels, see “About Incremental and Resumed Dumps”.


# xfsdump -f /dev/tape -L testers_11_21_94 -M test_1 /disk2
xfsdump: version 2.0 - type ^C for status and control
xfsdump: level 0 dump of cumulus:/disk2
xfsdump: dump date: Wed Oct 25 16:19:13 1995
xfsdump: session id: d2a6123b-b21d-1001-8938-08006906dc5c
xfsdump: session label: “testers_11_21_94”
xfsdump: ino map phase 1: skipping (no subtrees specified)
xfsdump: ino map phase 2: constructing initial dump list
xfsdump: ino map phase 3: skipping (no pruning necessary)
xfsdump: ino map phase 4: skipping (size estimated in phase 2)
xfsdump: ino map phase 5: skipping (only one dump stream)
xfsdump: ino map construction complete
xfsdump: preparing drive
xfsdump: creating dump session media file 0 (media 0, file 0)
xfsdump: dumping ino map
xfsdump: dumping directories
xfsdump: dumping non-directory files
xfsdump: ending media file
xfsdump: media file size 16777216 bytes
xfsdump: dumping session inventory
xfsdump: beginning inventory media file
xfsdump: media file 1 (media 0, file 1)
xfsdump: ending inventory media file
xfsdump: inventory media file size 4194304 bytes
xfsdump: writing stream terminator
xfsdump: beginning media stream terminator
xfsdump: media file 2 (media 0, file 2)
xfsdump: ending media stream terminator
xfsdump: media stream terminator size 2097152 bytes
xfsdump: I/O metrics: 3 by 2MB ring; 14/22 (64%) records streamed; 145889B/s
xfsdump: dump complete: 141 seconds elapsed

In this case, a session label (-L option) and a media label (-M option) are supplied, and the entire filesystem is dumped. Since no verbosity option is supplied, the default of verbose is used, resulting in the detailed screen output. The dump inventory is updated with the record of this backup because the -J option is not specified.

Following is an example of a backup of a subdirectory of a filesystem. In the following example, the verbosity is set to silent, and the dump inventory is not updated (-J option):

# xfsdump -f /dev/tape -v silent -J -s people/fred /usr

The subdirectory backed up (/usr/people/fred) was specified relative to the filesystem, so the specification did not include the name of the filesystem (in this case, /usr). Because /usr may be a very large filesystem and the -v silent option was used, this could take a long time during which there would be no screen output.

Specifying a Remote Tape Drive

To back up data to a remote tape drive, use the standard remote system syntax, specifying the system (by hostname if supported by a name server or IP address if not) followed by a colon (:), then the pathname of the special file.


Note: For remote backups, use the variable block size tape device if the device supports variable block size operation; otherwise, use the fixed block size device. For more information, see intro(7) .

The following example shows a subtree backup to a remote tape device:

# xfsdump -f magnolia:/dev/tape -L mag_10-95 -s engr /disk2
xfsdump: version 2.0 - type ^C for status and control
xfsdump: level 0 dump of cumulus:/disk2
xfsdump: dump date: Wed Oct 25 16:27:39 1995
xfsdump: session id: d2a6124b-b21d-1001-8938-08006906dc5c
xfsdump: session label: “mag_10-95”
xfsdump: ino map phase 1: parsing subtree selections
xfsdump: ino map phase 2: constructing initial dump list
xfsdump: ino map phase 3: pruning unneeded subtrees
xfsdump: ino map phase 4: estimating dump size
xfsdump: ino map phase 5: skipping (only one dump stream)
xfsdump: ino map construction complete
xfsdump: preparing drive
xfsdump: positioned at media file 0: dump 0, stream 0
xfsdump: positioned at media file 1: dump 0, stream 0
xfsdump: positioned at media file 2: dump 0, stream 0
xfsdump: stream terminator found
xfsdump: creating dump session media file 0 (media 0, file 2)
xfsdump: dumping ino map
xfsdump: dumping directories
xfsdump: dumping non-directory files
xfsdump: ending media file
xfsdump: media file size 6291456 bytes
xfsdump: dumping session inventory
xfsdump: beginning inventory media file
xfsdump: media file 1 (media 0, file 3)
xfsdump: ending inventory media file
xfsdump: inventory media file size 4194304 bytes
xfsdump: writing stream terminator
xfsdump: beginning media stream terminator
xfsdump: media file 2 (media 0, file 4)
xfsdump: ending media stream terminator
xfsdump: media stream terminator size 2097152 bytes
xfsdump: I/O metrics: 3 by 2MB ring; 12/22 (55%) records streamed; 99864B/s
xfsdump: dump complete: 149 seconds elapsed

In this case, /disk2/engr is backed up to the variable block size tape device on the remote system magnolia . Existing dumps on the tape mounted on magnolia were skipped before recording the new data.


Note: The superuser account on the local system must be able to rsh to the remote system without a password. For more information, see hosts.equiv(4) .


Backing Up to a File

You can back up data to a file instead of a device. In the following example, a file (Makefile) and a directory ( Source) are backed up to a dump file (monday_backup ) in /usr/tmp on the local system:

# xfsdump -f /usr/tmp/monday_backup -v silent -J -s \
people/fred/Makefile -s people/fred/Source /usr

You may also dump to a file on a remote system, but the file must be in the remote system's /dev directory. For example, the following command backs up the /usr/people/fred subdirectory on the local system to the regular file /dev/fred_mon_12-2 on the remote system theduke:

# xfsdump -f theduke:/dev/fred_mon_12-2 -s people/fred /usr

Alternatively, you could dump to any remote file if that file is on an NFS-mounted filesystem. In any case, permission settings on the remote system must allow you to write to the file.

For information on using the standard input and standard output capabilities of xfsdump and xfsrestore to pipe data between filesystems or across the network, see “Using xfsdump and xfsrestore to Copy Filesystems”.

Reusing Tapes

When you use a new tape as the media object of a dump session, xfsdump begins writing dump data at the beginning of the tape without prompting. If the tape already has dump data on it, xfsdump begins writing data after the last dump stream, again without prompting.

If, however, the tape contains data that is not from a dump session, xfsdump prompts you before continuing:

# xfsdump -f /dev/tape /test 
xfsdump: version X.X - type ^C for status and control
xfsdump: dump date: Fri Dec 2 11:25:19 1994
xfsdump: level 0 dump
xfsdump: session id: d23cc072-b21d-1001-8f97-080069068eeb
xfsdump: preparing tape drive
xfsdump: this tape contains data that is not part of an XFS dump
xfsdump: do you want to overwrite this tape?
type y to overwrite, n to change tapes or abort (y/n):

You must answer y if you want to continue with the dump session, or n to quit. If you answer y, the dump session resumes and the tape is overwritten. If you do not respond to the prompt, the session eventually times out.


Note: This means that an automatic backup, for example one initiated by a crontab entry, will not succeed unless you specified the -F option with the xfsdump command, which forces it to overwrite the tape rather than prompt for approval.


Erasing Used Tapes

Erase preexisting data on tapes with the mt erase command. Make sure the tape is not write-protected. For example, to prepare a used tape in the local default tape drive, enter:

# mt -f /dev/tape erase


Caution: This erases all data on the tape, including any dump sessions

The tape can now be used by xfsdump without prompting for approval.

About Incremental and Resumed Dumps

Incremental dumps are a way of backing up less data at a time but still preserving current versions of all your backed-up files, directories, and so on. Incremental backups are organized numerically by levels from 0 through 9. A level-0 dump always backs up the complete filesystem. A dump level of any other number backs up all files that have changed since a dump with a lower dump level number.

For example, if you perform a level-2 backup on a filesystem one day and your next dump is a level-3 backup, only those files that have changed since the level-2 backup are dumped with the level-3 backup. In this case, the level-2 backup is called the base dump for the level-3 backup. The base dump is the most recent backup of that filesystem with a lower dump level number.

Resumed dumps work in much the same way. When a dump is resumed after it has been interrupted, the remaining files that had been scheduled to be backed up during the interrupted dump session are backed up, and any files that changed during the interruption are also backed up.


Note: You must restore an interrupted dump as if it is an incremental dump (see“Performing Cumulative Restores with xfsrestore”).


Performing an Incremental Dump

In the following example, a level-0 dump is the first backup written to a new tape:

# xfsdump -f /dev/tape -l 0 -M Jun_94 -L week_1 -v silent /usr

A week later, a level-1 dump of the filesystem is performed on the same tape:

# xfsdump -f /dev/tape -l 1 -L week_2 /usr

The tape is forwarded past the existing dump data and the new data from the level 1 dump is written after it. (Note that it is not necessary to specify the media label for each successive dump on a media object.)

A week later, a level 2 dump is taken and so on, for the four weeks of a month in this example, the fourth week being a level 3 dump (up to nine dump levels are supported):

# xfsdump -f /dev/tape -l 2 -L week_3 /usr

For information on the proper procedure for restoring incremental dumps, see“Performing Cumulative Restores with xfsrestore”.

Performing a Resumed Dump

You can interrupt a dump session and resume it later. To interrupt a dump session, type the interrupt character (typically <CTRL-C> ). You receive a list of options that allow you to interrupt the session, change verbosity level, or resume the session.

In the following example, xfsdump is interrupted after dumping approximately 37% of a filesystem:

# xfsdump -f /dev/tape -M march95 -L week_1 -v silent /disk2
========================= status and control dialog ==========================
status at 16:49:16: 378/910 files dumped, 37.8% complete, 32 seconds elapsed
please select one of the following operations
1: interrupt this session
2: change verbosity
3: display metrics
4: other controls
5: continue (default) (timeout in 60 sec)
 -> 1
please confirm
1: interrupt this session
2: continue (default) (timeout in 60 sec)
 -> 1
interrupt request accepted
--------------------------------- end dialog ---------------------------------
xfsdump: initiating session interrupt
xfsdump: dump interrupted prior to ino 1053172 offset 0

You can later continue the dump by including the-R option and a different session label:

# xfsdump -f /dev/tape -R -L week_1.contd -v silent /disk2p

Any files that were not backed up before the interruption, and any file changes that were made during the interruption, are backed up after the dump is resumed.


Note: Use of the -R option requires that the dump was made with a dump inventory taken, that is, the -J option was not used with xfsdump.


Examining xfsdump Archives

This section describes how to use the xfsdump command to view an xfsdump inventory.

The xfsdump inventory is maintained in the directory  /var/xfsdump created by xfsdump. You can view the dump inventory at any time with the xfsdump -I command. With no other arguments, xfsdump -I displays the entire dump inventory. (The xfsdump -I command does not require root privileges.)

The following output presents a section of a dump inventory:

# xfsdump -I | more
file system 0:
        fs id:          d23cb450-b21d-1001-8f97-080069068eeb
        session 0:
                mount point:    magnolia.abc.xyz.com:/test
                device:         magnolia.abc.xyz.com:/dev/rdsk/dks0d3s2
                time:           Mon Nov 28 11:44:04 1994
                session label:  ""
                session id:     d23cbf44-b21d-1001-8f97-080069068eeb
                level:          0
                resumed:        NO
                subtree:        NO
                streams:        1
                stream 0:
                        pathname:       /dev/tape
                        start:          ino 4121 offset 0
                        end:            ino 0 offset 0
                        interrupted:    YES
                        media files:    2
                        media file 0:
                                mfile index:    0
---more---

The dump inventory records are presented sequentially and are indented to illustrate the hierarchical order of the dump information.

You can view a subset of the dump inventory by specifying the level of depth (1, 2, or 3) that you want to view. For example, specifying depth=2 filters out a lot of the specific dump information, as you can see by comparing the previous output with the following:

# xfsdump -I depth=2
file system 0:
        fs id:          d23cb450-b21d-1001-8f97-080069068eeb
        session 0:
                mount point:    magnolia.abc.xyz.com:/test
                device:         magnolia.abc.xyz.com:/dev/rdsk/dks0d3s2
                time:           Mon Nov 28 11:44:04 1994
                session label:  ""
                session id:     d23cbf44-b21d-1001-8f97-080069068eeb
                level:          0
                resumed:        NO
                subtree:        NO
                streams:        1
        session 1:
                mount point:    magnolia.abc.xyz.com:/test
                device:         magnolia.abc.xyz.com:/dev/rdsk/dks0d3s2
               ...

You can also view a filesystem-specific inventory by specifying the filesystem mount point with the mnt option. The following output shows an example of a dump inventory display in which the depth is set to 1, and only a single filesystem is displayed:

# xfsdump -I depth=1,mnt=magnolia.abc.xyz.com:/test
filesystem 0:
        fs id:          d23cb450-b21d-1001-8f97-080069068eeb

You can also look at a list of contents on the dump media itself by using the-t option with xfsrestore. See “Displaying the Contents of the Dump Media with xfsrestore ”.

About xfsrestore

This section discusses the following:

For more information, see the xfsrestore(8) man page.

xfsrestore Syntax

You can use the xfsrestore command to view and extract data from the dump data created by xfsdump.

You can get a summary of xfsrestore syntax with the -h option:

# xfsrestore -h
xfsrestore: version X.X
xfsrestore: usage: xfsrestore [ -a <alt. workspace dir> ... ]
                     [ -e (don't overwrite existing files) ]
                     [ -f <source> ... ]
                     [ -h (help) ]
                     [ -i (interactive) ]
                     [ -n <file> (restore only if newer than) ]
                     [ -o (restore owner/group even if not root) ]
                     [ -p <seconds between progress reports> ]
                     [ -r (cumulative restore) ]
                     [ -s <subtree> ... ]
                     [ -t (contents only) ]
                     [ -v <verbosity {silent, verbose, trace}> ]
                     [ -A (don't restore extended file attributes) ]
                     [ -C (check tape record checksums) ]
                     [ -D (restore DMAPI event settings) ]
                     [ -E (don't overwrite if changed) ]
                     [ -F (don't prompt) ]
                     [ -I (display dump inventory) ]
                     [ -J (inhibit inventory update) ]
                     [ -L <session label> ]
                     [ -N (timestamp messages) ]
                     [ -O <options file> ]
                     [ -P (pin down I/O buffers) ]
                     [ -Q (force interrupted session completion) ]
                     [ -R (resume) ]
                     [ -S <session id> ]
                     [ -T (don't timeout dialogs) ]
                     [ -U (unload media when change needed) ]
                     [ -V (show subsystem in messages) ]
                     [ -W (show verbosity in messages) ]
                     [ -X <excluded subtree> ... ]
                     [ -Y <I/O buffer ring length> ]
                     [ -Z (miniroot restrictions) ]
                     [ - (stdin) ]
                     [ <destination> ]

Use xfsrestore to restore data backed up with xfsdump. You can restore files, subdirectories, and filesystems regardless of the way they were backed up. For example, if you back up an entire filesystem in a single dump, you can select individual files and subdirectories from within that filesystem to restore.

You can use xfsrestore interactively or noninteractively. With interactive mode, you can peruse the filesystem or files backed up, selecting those you want to restore. In noninteractive operation, a single command line can restore selected files and subdirectories, or an entire filesystem. You can restore data to its original filesystem location or any other location in an XFS filesystem.

By using successive invocations of xfsrestore, you can restore incremental dumps on a base dump. This restores data in the same sequence it was dumped.

Displaying the Contents of the Dump Media with xfsrestore

To list the contents of the dump tape currently in the local tape drive, type:

# xfsrestore -f /dev/tape -t -v silent | more
xfsrestore: dump session found
xfsrestore: session label: "week_1"
xfsrestore: session id: d23cbcb4-b21d-1001-8f97-080069068eeb
xfsrestore: no media label
xfsrestore: media id: d23cbcb5-b21d-1001-8f97-080069068eeb
do you want to select this dump? (y/n): y
selected
one
A/five
people/fred/TOC
people/fred/ch3.doc
people/fred/ch3TOC.doc
people/fred/questions
A/four
people/fred/script_0
people/fred/script_1
people/fred/script_2
people/fred/script_3
people/fred/sub1/TOC
people/fred/sub1/ch3.doc
people/fred/sub1/ch3TOC.doc
people/fred/sub1/questions
people/fred/sub1/script_0
people/fred/sub1/script_1
people/fred/sub1/script_2
people/fred/sub1/script_3
people/fred/sub1/xdump1.doc
people/fred/sub1/xdump1.doc.backup
people/fred/sub1/xfsdump.doc
people/fred/sub1/xfsdump.doc.auto
people/fred/sub1/sub2/TOC
---more---

Performing Simple Restores with xfsrestore

A simple restore is a non-cumulative restore (for information on restoring incremental dumps, refer to “Performing Cumulative Restores with xfsrestore”). An example of a simple, noninteractive use of xfsrestore is:

# xfsrestore -f /dev/tape /disk2
xfsrestore: version 2.0 - type ^C for status and control
xfsrestore: searching media for dump
xfsrestore: preparing drive
xfsrestore: examining media file 0

 =========================== dump selection dialog ============================

the following dump has been found on drive 0

hostname: cumulus
mount point: /disk2
volume: /dev/rdsk/dks0d2s0
session time: Wed Oct 25 16:59:00 1995
level: 0
session label: “tape1”
media label: “media1”
file system id: d2a602fc-b21d-1001-8938-08006906dc5c
session id: d2a61284-b21d-1001-8938-08006906dc5c
media id: d2a61285-b21d-1001-8938-08006906dc5c

restore this dump?
1: skip
2: restore (default)
 -> 2
this dump selected for restoral

 --------------------------------- end dialog ---------------------------------

xfsrestore: using online session inventory
xfsrestore: searching media for directory dump
xfsrestore: reading directories
xfsrestore: directory post-processing
xfsrestore: restoring non-directory files
xfsrestore: I/O metrics: 3 by 2MB ring; 9/13 (69%) records streamed; 204600B/s
xfsrestore: restore complete: 104 seconds elapsed

In this case, xfsrestore went to the first dump on the tape and asked if this was the dump to restore. If you had entered 1 for “skip,” xfsrestore would have proceeded to the next dump on the tape (if there was one) and asked if this was the dump you wanted to restore.

You can request a specific dump if you used xfsdump with a session label. For example:

# xfsrestore -f /dev/tape -L Wed_11_23 /usr
xfsrestore: version X.X - type ^C for status and control
xfsrestore: preparing tape drive
xfsrestore: dump session found
xfsrestore: advancing tape to next media file
xfsrestore: dump session found
xfsrestore: restore of level 0 dump of magnolia.abc.xyz.com:/usr created Wed Nov 23 11:17:54 1994
xfsrestore: beginning media file
xfsrestore: reading ino map
xfsrestore: initializing the map tree
xfsrestore: reading the directory hierarchy
xfsrestore: restoring non-directory files
xfsrestore: ending media file
xfsrestore: restoring directory attributes
xfsrestore: restore complete: 200 seconds elapsed

In this way you recover a dump with a single command line and do not have to answer y or n to the prompts asking you if the dump session found is the correct one. To be even more exact, use the -S option and specify the unique session ID of the particular dump session:

# xfsrestore -f /dev/tape -S \ d23cbf47-b21d-1001-8f97-080069068eeb /usr2/tmp
xfsrestore: version X.X - type ^C for status and control
xfsrestore: preparing tape drive
xfsrestore: dump session found
xfsrestore: advancing tape to next media file
xfsrestore: advancing tape to next media file
xfsrestore: dump session found
xfsrestore: restore of level 0 dump of magnolia.abc.xyz.com:/test resumed Mon Nov 28 11:50:41 1994
xfsrestore: beginning media file
xfsrestore: media file 0 (media 0, file 2)
xfsrestore: reading ino map
xfsrestore: initializing the map tree
xfsrestore: reading the directory hierarchy
xfsrestore: restoring non-directory files
xfsrestore: ending media file
xfsrestore: restoring directory attributes
xfsrestore: restore complete: 229 seconds elapsed

You can find the session ID by viewing the dump inventory (see “Examining xfsdump Archives ”). Session labels might be duplicated, but session IDs never are.

Restoring Individual Files with xfsrestore

On the xfsrestore command line, you can specify an individual file or subdirectory to restore. In this example, the file people/fred/notes is restored and placed in the /usr/tmp directory (that is, the file is restored in /usr/tmp/people/fred/notes):

# xfsrestore -f /dev/tape -L week_1 -s people/fred/notes /usr/tmp

You can also restore a file “in place” that is, restore it directly to where it came from in the original backup.


Note: However, if you do not use the -e, -E, or -n option, you will overwrite any existing files of the same name.

In the following example, the subdirectory people/fred is restored in the destination /usr, which overwrites any files and subdirectories in /usr/people/fred with the data on the dump tape:

# xfsrestore -f /dev/tape -L week_1 -s people/fred /usr

Performing Network Restores with xfsrestore

You can use standard network references to specify devices and files on the network. For example, to use the tape drive on a network host named magnolia as the source for a restore, you can use the following command:

# xfsrestore -f magnolia:/dev/tape -L 120694u2 /usr2
xfsrestore: version X.X - type ^C for status and control
xfsrestore: preparing tape drive
xfsrestore: dump session found
xfsrestore: advancing tape to next media file
xfsrestore: dump session found
xfsrestore: restore of level 0 dump of magnolia.abc.xyz.com:/usr2 created Tue Dec 6 10:55:17 1994
xfsrestore: beginning media file
xfsrestore: media file 0 (media 0, file 1)
xfsrestore: reading ino map
xfsrestore: initializing the map tree
xfsrestore: reading the directory hierarchy
xfsrestore: restoring non-directory files
xfsrestore: ending media file
xfsrestore: restoring directory attributes
xfsrestore: restore complete: 203 seconds elapsed

In this case, the dump data is extracted from the tape on magnolia, and the destination is the directory /usr2 on the local system. For an example of using the standard input option of xfsrestore, see “Using xfsdump and xfsrestore to Copy Filesystems”.

Performing Interactive Restores with xfsrestore

Use the -i option of xfsrestore to perform interactive file restoration. With interactive restoration, you can use the commands ls, pwd, and cd to peruse the filesystem, and the add and delete commands to create a list of files and subdirectories you want to restore. Then you can enter the extract command to restore the files, or quit to exit the interactive restore session without restoring files. (The use of wildcards is not allowed with these commands.)


Note: Interactive restore is not allowed when the xfsrestore source is standard input ( stdin).

The following screen output shows an example of a simple interactive restoration.

# xfsrestore -f /dev/tape -i -v silent .
xfsrestore: dump session found
xfsrestore: no session label
xfsrestore: session id:    d23cbeda-b21d-1001-8f97-080069068eeb
xfsrestore: no media label
xfsrestore: media id:      d23cbedb-b21d-1001-8f97-080069068eeb
do you want to select this dump? (y/n): y
selected

 --- interactive subtree selection dialog ---

the following commands are available:
        pwd 
        ls [ { <name>, ".." } ]
        cd [ { <name>, ".." } ]
        add [ <name> ]
        delete [ <name> ]
        extract 
        quit 
        help 
 -> ls
            4122 people/
            4130 two 
            4126 A/
            4121 one 
 -> add two
 -> cd people
 -> ls
            4124 fred/
 -> add fred
 -> ls
    *       4124 fred/
 -> extract

 ---------------- end dialog ----------------

In the interactive restore session above, the subdirectory  people/fred and the file two were restored relative to the current working directory (“. ”). An asterisk (*) in your ls output indicates your selections.

Performing Cumulative Restores with xfsrestore

Cumulative restores sequentially restore incremental dumps to re-create filesystems and are also used to restore interrupted dumps. To perform a cumulative restore of a filesystem, begin with the media object that contains the base-level dump and recover it first, then recover the incremental dump with the next higher dump level number, then the next, and so on. Use the -r option to inform xfsrestore that you are performing a cumulative recovery.

In the following example, the level-0 base dump and succeeding higher-level dumps are on /dev/tape. First the level-0 dump is restored, then each higher-level dump in succession:

# /usr/tmp/xfsrestore -f /dev/tape -r -v silent .

 =========================== dump selection dialog ============================

the following dump has been found on drive 0

hostname: cumulus
mount point: /disk2
volume: /dev/rdsk/dks0d2s0
session time: Wed Oct 25 14:37:47 1995
level: 0
session label: "week_1"
media label: "Jun_94"
file system id: d2a602fc-b21d-1001-8938-08006906dc5c
session id: d2a60b26-b21d-1001-8938-08006906dc5c
media id: d2a60b27-b21d-1001-8938-08006906dc5c

restore this dump?
1: skip
2: restore (default)
 -> Enter
this dump selected for restoral

 --------------------------------- end dialog ---------------------------------

#

Next, enter the same command again. The program goes to the next dump and again you select the default:

# xfsrestore -f /dev/tape -r -v silent .

 =========================== dump selection dialog ============================

the following dump has been found on drive 0

hostname: cumulus
mount point: /disk2
volume: /dev/rdsk/dks0d2s0
session time: Wed Oct 25 14:40:54 1995
level: 1
session label: "week_2"
media label: "Jun_94"
file system id: d2a602fc-b21d-1001-8938-08006906dc5c
session id: d2a60b2b-b21d-1001-8938-08006906dc5c
media id: d2a60b27-b21d-1001-8938-08006906dc5c

restore this dump?
1: skip
2: restore (default)
 -> Enter
this dump selected for restoral

 --------------------------------- end dialog ---------------------------------
#

You then repeat this process until you have recovered the entire sequence of incremental dumps. The full and latest copy of the filesystem will then have been restored. In this case, it is restored relative to “ .”, that is, in the directory you are in when the sequence of xfsrestore commands is issued.

Restore an interrupted dump just as if it were an incremental dump. Use the -r option to inform xfsrestore that you are performing an incremental restore, and answer y and n appropriately to select the proper “increments” to restore (see “Performing Cumulative Restores with xfsrestore”).


Note: If you try to restore an interrupted dump as if it were a non-interrupted, non-incremental dump, the portion of the dump that occurred before the interruption is restored, but not the remainder of the dump. You can determine if a dump is an interrupted dump by looking in the online inventory.

Following is an example of a dump inventory showing an interrupted dump session (the crucial fields are in bold type):

# xfsdump -I depth=3,mobjlabel=AugTape,mnt=indy4.xyz.com:/usr
file system 0:
        fs id:          d23cb450-b21d-1001-8f97-080069068eeb
        session 0:
                mount point:    indy4.xyz.com.com:/usr
                device:         indy4.xyz.com.com:/dev/rdsk/dks0d3s2
                time:           Tue Dec  6 15:01:26 1994
                session label:  "180894usr"
                session id:     d23cc0c3-b21d-1001-8f97-080069068eeb
                level:          0
                resumed:        NO
                subtree:        NO
                streams:        1
                stream 0:
                        pathname:       /dev/tape
                        start:          ino 4121 offset 0
                        end:            ino 0 offset 0
                        interrupted:    YES
                        media files:    2
        session 1:
                mount point:    indy4.xyz.com.com:/usr
                device:         indy4.xyz.com.com:/dev/rdsk/dks0d3s2
                time:           Tue Dec  6 15:48:37 1994
                session label:  "Resumed180894usr"
                session id:     d23cc0cc-b21d-1001-8f97-080069068eeb
                level:          0
                resumed:        YES
                subtree:        NO
                streams:        1
                stream 0:
                        pathname:       /dev/tape
                        start:          ino 4121 offset 0
                        end:            ino 0 offset 0
                        interrupted:    NO
                        media files:    2
...

From this it can be determined that session 0 was interrupted and then resumed and completed in session 1.

To restore the interrupted dump session in the example above, use the following sequence of commands:

# xfsrestore -f /dev/tape -r -L 180894usr .
# xfsrestore -f /dev/tape -r -L Resumed180894usr .

This restores the entire /usr backup relative to the current directory. (You should remove the housekeeping directory from the destination directory when you are finished.)

Interrupting xfsrestore

In a manner similar to xfsdump interruptions, you can interrupt an xfsrestore session. This allows you to interrupt a restore session and then resume it later. To interrupt a restore session, type the interrupt character (typically <CTRL-C>). You receive a list of options, which include interrupting the session or continuing.

# xfsrestore -f /dev/tape -v silent /disk2

 =========================== dump selection dialog ============================

the following dump has been found on drive 0

hostname: cumulus
mount point: /disk2
volume: /dev/rdsk/dks0d2s0
session time: Wed Oct 25 17:20:16 1995
level: 0
session label: "week1"
media label: "newtape"
file system id: d2a602fc-b21d-1001-8938-08006906dc5c
session id: d2a6129e-b21d-1001-8938-08006906dc5c
media id: d2a6129f-b21d-1001-8938-08006906dc5c

restore this dump?
1: skip
2: restore (default)
 -> 2
this dump selected for restoral

 --------------------------------- end dialog ---------------------------------


 ========================= status and control dialog ==========================

status at 17:23:52: 131/910 files restored, 14.4% complete, 42 seconds elapsed

please select one of the following operations
1: interrupt this session
2: change verbosity
3: display metrics
4: other controls
5: continue (default) (timeout in 60 sec)
 -> 1

please confirm
1: interrupt this session
2: continue (default) (timeout in 60 sec)
 -> 1
interrupt request accepted

 --------------------------------- end dialog ---------------------------------

xfsrestore: initiating session interrupt

Resume the xfsrestore session with the -R option:

# xfsrestore -f /dev/tape -R -v silent /disk2

Data recovery continues from the point of the interruption.

About the housekeeping and orphanage Directories

The xfsrestore utility can create two subdirectories in the destination called housekeeping and orphanage:

  • housekeeping is a temporary directory used during cumulative recovery to pass information from one invocation of xfsrestore to the next. It must not be removed during the process of performing the cumulative recovery but should be removed after the cumulative recovery is completed.

  • orphanage is created if a file or subdirectory is restored that is not referenced in the filesystem structure of the dump. For example, if you dump a very active filesystem, it is possible for new files to be in the non-directory portion of the dump, yet none of the directories dumped reference that file. A warning message is displayed, and the file is placed in the orphanage directory, named with its original inode number and generation count (for example, 123479.14).

Using xfsdump and xfsrestore to Copy Filesystems

You can use xfsdump and xfsrestore to pipe data across filesystems or across the network with a single command line. By piping xfsdump standard output to xfsrestore standard input you create an exact copy of a filesystem.

For example, to make a copy of /usr/people/fred in the /usr2 directory, enter:

# xfsdump -J -s people/fred - /usr | xfsrestore - /usr2

To copy /usr/people/fred to the network host magnolia's /usr/tmp directory:

# xfsdump -J -s people/fred - /usr | rsh magnolia \
xfsrestore - /usr/tmp

This creates the directory /usr/tmp/people/fred on magnolia.


Note: The superuser account on the local system must be able to rsh to the remote system without a password. For more information, seehosts.equiv(4).