Restoring is the process of copying back to the system those objects you previously saved to tapes. When you restore an object of any kind, you are recovering the object as it existed at the time it was saved. If you made some changes after you saved the object, the restored copy will not be up to date. This problem emphasizes the need to save as often as possible.
To restore an object, you use different commands, depending on the type of object. This section presents the most important restore operations.
Restoring a library means restoring the library object (*LIB) itself and all the objects contained in the library at the time you saved the library. To restore a library, use the Restore Library (RSTLIB) command. Here are some examples:
RSTLIB SAVLIB(ARLIB) DEV(TAP01)
This command restores library ARLIB from the tape mounted in tape drive TAP01. Note that the name of the library, ARLIB, goes in parameter SAVLIB. Although confusing, this is the way the RSTLIB command has been designed. Remember that ARLIB is the name of the library that was saved.
RSTLIB SAVLIB(ARLIB) DEV(TAP01) RSTLIB(ARDATA)
This command is a variation of the previous one. The tape contains library ARLIB (the saved library, SAVLIB), but you want to restore the library into the system (RSTLIB) with the name ARDATA. In other words, library ARLIB is restored with a different name. When the RSTLIB command ends, you will have a library called ARDATA in your system.
RSTLIB SAVLIB(ARLIB) DEV(TAP01) OPTION(*ALL)
This command is identical to the first one because the OPTION parameter defaults to *ALL. All objects in the saved library, ARLIB, are restored to your system, regardless of whether your system's ARLIB library already contains the objects.
In other words, your system has a library named ARLIB on disk that contains file A but does not have file B. The version of ARLIB you have on the tape contains both files, A and B. When you restore ARLIB with OPTION(*ALL), both files are restored. File A is overwritten and file B is created.
RSTLIB SAVLIB(ARLIB) DEV(TAP01) OPTION(*NEW)
This command operates like the previous one except that only file B would be restored because A already exists in your system's ARLIB. The OPTION parameter also can have value *OLD (its meaning is opposite of *NEW) and *FREE. *FREE is used only when you saved a library with STG(*FREE), which is usually not recommended.
RSTLIB SAVLIB(*NONSYS) DEV(TAP01 TAP02)
This command restores all nonsystem libraries contained on the tape mounted in TAP01. When that tape is exhausted, the system automatically continues with TAP02 while TAP01 rewinds.
You don't have to restore a whole library if you need only a few of the objects contained in it. Using the Restore Object (RSTOBJ) command, you can restore individual objects.
Here are a few examples:
RSTOBJ OBJ(*ALL) SAVLIB(ARLIB) DEV(TAP01) OBJTYPE(*DTAARA)
This command restores all data areas that were saved from library ARLIB. The system uses the tape drive TAP01 for the restore.
RSTOBJ OBJ(AR001CL AR001RG) SAVLIB(ARLIB) DEV(TAP01) + OBJTYPE(*ALL)
This command restores objects AR001CL and AR001RG (no matter what the type) from the tape mounted in TAP01.
RSTOBJ OBJ(QRPGSRC) SAVLIB(PGMLIB) DEV(TAP01) + OBJTYPE(*FILE) FILEMBR((QRPGSRC (MBR1 MBR2))) + MBROPT(*ALL)
This command restores members MBR1 and MBR2 from file QRPGSRC, as saved in library PGMLIB on tape device TAP01.
Use the Restore Document Library Object (RSTDLO) to restore documents and folders from tape. Here are two examples:
RSTDLO DLO(*ALL) DEV(TAP01)
This command restores all documents and folders previously saved on the tape mounted in TAP01.
RSTDLO DLO(FRANKIE.DOC) DEV(TAP01) SAVFLR(*ANY) + RENAME(FRANK.DOC) RSTFLR(MEMOS/PERSONAL)
This command assumes that the tape in TAP01 contains a document named FRANKIE.DOC (in any folder) that you want to restore. Once the document is restored, however, its name is changed to FRANK.DOC, and it is placed in folder MEMOS/PERSONAL.
To restore saved objects to the IFS, use the Restore Objects (RST) command. The comments made earlier about its counterpart, SAV, apply equally to RST. First, RST has only one required parameter—DEV—and most of the optional parameters are the same. Second, all objects, even those in the library file system, must be specified in the directory-like notation. A third similarity is that omission of the OBJ parameter limits the restore operation to the current directory.
The following command, which comes from IBM's CL reference material, restores all objects except those in libraries and folders:
RST DEV('/QSYS.LIB/TAP01.DEVD') OBJ(('/*') ('/QSYS.LIB' *OMIT) ('/QDLS' *OMIT))
If you have a tape on which you have saved the configuration objects (such as device descriptions and controllers) using either the SAVSYS or SAVCFG command, you can restore individual configuration objects from that tape using the Restore Configuration (RSTCFG) command. For example:
RSTCFG OBJ(DSP32 DSP35 PRT02) OBJTYPE(*DEVD) ENDOPT(*UNLOAD)
This command restores the device descriptions DSP32, DSP35, and PRT02. When the restore is completed, the tape is unloaded.
RSTCFG OBJ(*ALL) ENDOPT(*UNLOAD) OUTPUT(*PRINT)
This command restores all configuration objects from the tape. It also prints a report that lists all objects that were successfully restored, those that were not restored, and those that were excluded.