Saving and restoring spooled files
For i5/OS V5R4 or later, you can use any of the methods described here to save and restore spooled files. This information contains a table that lists the commands and APIs in order of preference.
For releases prior to V5R4, you must use indirect methods for saving and restoring spooled files. These indirect methods might not preserve all of the attributes.
Save Methods | Restore Methods | Spooled file attributes preserved | When used |
---|---|---|---|
SAVLIB, SAVOBJ commands SAVRSTLIB, SAVRSTOBJ commands, QSRSAVO API, Save menu options 21-23 | RSTLIB, RSTOBJ commands SAVRSTLIB, SAVRSTOBJ commands, QSRRSTO API, Restore menu options 21-23 | Data and all attributes | i5/OS V5R4 and later |
QSPOPNSP, QSPGETSP, QUSRSPLA APIs | QSPCRTSP, QSPPUTSP, QSPCLOSP APIs | Data, but not all attributes | Any release |
CPYSPLF, SAVOBJ commands | CPYF command | Textual data only | Any release |
When you save an output queue with the save commands, menu, or QSRSAVO API, you can choose to save all its spooled files. You can do this by specifying *ALL for the Spooled file data (SPLFDTA) command parameter, menu prompt or API key. When you restore output queues with the restore commands, menu, or QSRRSTO API, you can choose to restore any saved spooled files that do not already exist on the system. You can do this by specifying *NEW for the SPLFDTA parameter, prompt, or key. With the QSRSAVO and QSRRSTO APIs, you can also choose to save or restore spooled files by using a set of selection criteria. If you save spooled files with the QSRSAVO API using selection criteria and the *SPLF special library value, then you must use the QSRRSTO API with the *SPLF special library value to restore the spooled files.
- Create an output queue to store the spooled files.
CRTOUTQ OUTQ(lib-name/que-name)
- Use the Work with Spooled File (WRKSPLF) command to list the spooled files.
- Use option 2, Change Spooled File Attributes (CHGSPLFA) command to move the spooled files you want to save to the output queue you created.
- Use the Save Object (SAVOBJ) command to save the spooled file data.
SAVOBJ OBJ(que-name) LIB(lib-name) DEV(dev-name) OBJTYPE(*OUTQ) SPLFDTA(*ALL)
- Restore spooled files that are not already on the system.
RSTOBJ OBJ(que-name) SAVLIB(lib-name) DEV(dev-name) OBJTYPE(*OUTQ) SPLFDTA(*NEW)
Using spooled file APIs
If your source or target system is earlier than V5R4, you can use spooled file APIs as an indirect method to save and restore spooled files. This method preserves the spooled file data stream but not all of the attributes.
- The spooled files are opened using the Open Spooled File (QSPOPNSP) API.
- The spooled file data is retrieved using the Get Spooled File Data (QSPGETSP) API.
- The spooled file attributes are retrieved using the User Spooled File Attributes (QUSRSPLA) API.
- The spooled files are created using the Create Spooled File (QSPCRTSP) API .
- The spooled file data is written to a new spooled file using the Put Spooled File Data (QSPPUTSP) API.
- The spooled file is closed using the Close Spooled File (QSPCLOSP) API.
You can find an example and a tool for using these APIs in the QUSRTOOL library in the TSRINFO member of the QATTINFO file.
Copying spooled files to database files
If your source or target system is earlier than V5R4, you can copy data between spooled files and database files as an indirect method to save and restore spooled files. This method copies textual data only and not advanced function attributes such as graphics and variable fonts. This method does not provide a complete solution for saving your spooled files.
The Copy Spooled File (CPYSPLF) command saves spooled file data to a database file. The Copy File (CPYF) command can copy data from a database file to a spooled file.