Restoring objects in directories

You can use the Restore Object (RST) command to restore objects that you have saved with the Save Object (SAV) command.

These commands are most commonly used to save and restore objects the root file system, the QOpenSys file system, and the QNTC file system.

  • If you have related objects, such as journals and journaled objects, you must ensure that you restore them in the correct sequence.
  • If you are restoring to a different system or different logical partitions, specify ALWOBJDIF(*ALL) when you are restoring directories.

You can use the RST command to restore the following items:

  • A specific object
  • A directory or subdirectory
  • An entire file system
  • Objects that meet search criteria
  • A list of object path names

You can also restore the items in the preceding list by using the Restore Object (QsrRestore) API.

For example, to restore all objects (or changed objects) in directories, use the following command:
RST DEV('/QSYS.LIB/media-device-name.DEVD')
    OBJ(('/*') ('/QSYS.LIB' *OMIT) ('/QDLS' *OMIT))
Note: This example is the same restore (RST) command that is issued under option 21 on the Restore menu.
When you restore individual objects from a tape file that contains many saved objects, you can improve the performance of the restore operation if you specify the following information:
  1. Tape file sequence number.

    The tape file sequence number is the quickest way to locate the tape file that contains the desired objects.

  2. Starting position.

    The starting position within the tape file for each object is provided by save operations when output to a streamfile or user space is requested.

This example restores the object FXX in directory JS200000, using a media library device NET3590 on volume LN4381 and specifying the saved object located at tape file sequence number (4488) and found at starting position '000000000001904900000000000019CAA'.
    OBJ(('/JS200000/FXX')) VOL(LN4381) ENDOPT(*LEAVE)
    SEQNBR(4488) POSITION(000000000001904900000000000019CAA)

You can rename an object or restore it to a different directory by using the new-name element of the object (OBJ) parameter.

The OBJ parameter on the RST command supports the use of wildcard characters and the directory hierarchy. When you have a specific subset of similar objects within a directory subtree that you want to restore, you can use the Name pattern (PATTERN) parameter to further define the objects that are identified in the (OBJ) parameter.

Some file systems allow you to name the same physical object different ways by using aliases and links. For examples of objects with links and how those objects are saved, see the Backing up your system topic.

In the example of Figure 1, FILEA in the JCHDIR directory and FILEB in the DRHDIR directory are both hard links to the same file. They point to the same object. They can have the same name or different names for the objects.

Figure 1. An object with hard links–Example
An object with hard links–Example

Table 1 shows several examples of how the system restores these objects. These examples assume that you use this SAV command: SAV OBJ('/UserDir/*'). The media volume contains OBJECT A and both hard links that point to the object.

Table 1. Restoring objects that have hard links
Object parameter on RST command Objects that are on the system before the RST command Objects after the RST command
RST OBJ('/UserDir/*') JCHDIR/FILEA The saved data is restored. The object DRHDIR/FILEB is created on the system. It points to the same object as JCHDIR/FILEA.
RST OBJ('/UserDir/DRHDIR/*') JCHDIR/FILEA A new object, DRHDIR/FILEB, is created. The JCHDIR/FILEA that exists on the system is not affected by the restore operation.
OBJ('/UserDir/*'), or
OBJ('/UserDir/JCHDIR/*'), or
JCHDIR/FILEA, DRHDIR/FILEB Data from the media copy of FILEA and FILEB is restored over the system copy because the same name is specified as a name that already exists on the system.
RST CRTPRNDIR If parent directories of objects being restored do not exist, the CRTPRNDIR command specifies if they should be created.
RST PRNDIROWN The PRNDIROWN command specifies the name of an existing user profile that will own parent directories created by the restore operation.

Figure 2 shows the symbolic link called customer that points in the CUSTLIB library.

Figure 2. An object with a symbolic link–Example
An object with hard links–Example

If you restore the customer object (RST OBJ('/customer')), you are restoring only the fact that it points to the CUSTMAS file, not the file itself. If the CUSTMAS file does not exist, the restore operation succeeds. However, if you try to use the customer object, you receive an error message. If you restore the CUSTMAS file or create it again, the symbolic link between customer and the CUSTMAS file is reestablished.