Save and restore spooled files

Start of change

Save and restore spooled files and all of their attributes. Prior to V5R4M0, you must use indirect methods to save and restore spooled files. These indirect methods may not preserve all of the attributes. This table summarizes the methods.

Table 1. Save and restore spooled files
Restore Methods Method descriptions Spooled file attributes preserved
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
QSPOPNSP, QSPGETSP, QUSRSPLA APIs QSPCRTSP, QSPPUTSP, QSPCLOSP APIs Data, but not all attributes
CPYSPLF, SAVOBJ commands CPYF command Textual data only

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.

This example describes how to save spooled files:
  1. Create an output queue to store the spooled files.
    CRTOUTQ OUTQ(lib-name/que-name) 
  2. Use the Work with Spooled File (WRKSPLF) command to list the spooled files.
  3. Use option 2, Change Spooled File Attributes (CHGSPLFA) command to move the spooled files you wish to save to the output queue you created.
  4. 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)
This example describes how to restore spooled files:
  1. Restore spooled files that are not already on the system.
    RSTOBJ OBJ(que-name) SAVLIB(lib-name) DEV(dev-name) 
    OBJTYPE(*OUTQ) SPLFDTA(*NEW)
End of change

Using spooled file APIs

If your source or target system is earlier than V5R4M0, 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.

To save spooled files:
  • 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.
To restore spooled files:
  1. The spooled files are created using the Create Spooled File (QSPCRTSP) API .
  2. The spooled file data is written to a new spooled file using the Put Spooled File Data (QSPPUTSP) API.
  3. The spooled file is closed using the Close Spooled File (QSPCLOSP) API.

The System API Reference in the iSeries™ Information Center includes information about these APIs. 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 V5R4M0, 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. Refer to Restoring Previous Release User Data to a New System in the Backup and Recovery book for more details.

View Entire GO SAVE checklistin the iSeries Information Center includes more information about menu options 21, 22, and 23 of the GO SAVE command.

Refer to Print restrictions in the Information center within the Print topic for restrictions of saving and restoring spooled files.

Related tasks
Save your entire server with GO SAVE: Option 21
Save user data with GO SAVE: Option 23
Related information
Save and restore spooled files