IBM Support

Saving and Restoring Spooled Files

Troubleshooting


Problem

This is a generalized document describing various ways to save and restore spooled files.

Resolving The Problem

There are many occasions when you want to know how to save and restore spooled files or duplicate them. The correct response depends on what you want to save/restore such as one spooled file, a small number of spooled files, all spooled files from one or more output queues, or the entire QSPL library.

For release V5R4 and later, you can save and restore spooled files and all of their attributes using the native SAVLIB, SAVOBJ, SAVRSTLIB, SAVRSTOBJ commands, the QSRSAVO API, and Save menu Options 21-23. For restoring, you can use the native RSTLIB, RSTOBJ, SAVRSTLIB, SAVRSTOBJ commands, the QSRRSTO API, and Restore menu Options 21-23. When you save an output queue with the save commands, the menu, or the QSRSAVO API, you can choose to save all of 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, the menu, or the 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, you must use the QSRRSTO API with the *SPLF special library value to restore the spooled files.

For previous releases, there are several operating system commands that are available and tools that can be created to support the requested functions. You should review one or more of the following items with your customer, based on what they intend or expect to accomplish:

Be advised that IBM's QUSRTOOL is provided as is and is not actively maintained. We neither support nor guarantee that the tool will do what it is intended or designed to do. The tool is designed for convenience rather than for disaster recovery and should be fully tested before being used.

Note: You cannot restore a spooled file that already exists on the system to a different library.

1.
To save all spooled files on the system, change the defaults for the system save using the SAVE menu:
GO SAVE
Select option 20. Define save system and user data defaults 
Change Spooled file data to *ALL and press <ENTER>
The next save operation using GO SAVE option 21. Entire system, 22. System data only or 23. All user data will include the spooled file data.
To restore the spooled files saved using GO SAVE:
GO RESTORE
Select one of the appropriate options based on how the data was saved:
   21. System and user data 
   22. System data only
   23. All user data   
2.
To save all spooled files on the system using the BACKUP menu, consider changing the command defaults for the SAVLIB command to SPLFDTA(*ALL). 
CHGCMDDFT CMD(QSYS/SAVLIB) NEWDFT('SPLFDTA(*ALL)')
GO BACKUP option 1. Run backup will then include spooled file data.
To restore the spooled files saved using GO BACKUP:
RSTOBJ OBJ(OUTQNAME) SAVLIB(OUTQLIB) DEV(OPTxx) OBJTYPE(*OUTQ) SPLFDTA(*NEW)
-or-
RSTOBJ OBJ(*ALL) SAVLIB(LibraryName) DEV(OPTxx) OBJTYPE(*OUTQ) SPLFDTA(*NEW)
3. Refer to document N1010238, Using CPYSPLF to Re-Create a Spooled File or Create a PC File, for a description of creating a database file (CRTPF) using copy spooled file (CPYSPLF) and save object (SAVOBJ) commands. RSTOBJ and CPYF commands can later be used to restore the saved spooled file and print the information from it. This is a good method for saving/restoring one or a limited number of your typical spooled files (without *AFPDS, and so on).
4. There is an IBM (free) QUSRTOOL to save/restore spooled file (SAVRSTSPLF) that requires an ILE C compiler. The SAVRSTSPLF tool provides a method for saving spooled files into a designated library (or device) and to restore and print them at a later time. It consists of the programs for creating ZSAVSPLF and ZRSTSPLF commands. On the ZSAVSPLF command, the spooled files to be saved can be selected by user, output queue, form type, or user data. The ZRSTSPLF command restores those files from the library or device to the output queue in which they were originally spooled. There are certain limitations to consider for SAVRSTSPLF tool. Refer to member TSRINFO in file QUSRTOOL/ATTINFO for further information on its description and tool creation steps. Command DSPSFWRSC can be used to determine whether the customer has 57xxCX2 (ILE C compiler) and 57xxSS1 Option 7 (example tools) products installed on the system or not.
5. Product 57xxBR1, Backup Recovery and Media Services, generally known as BRMS, can be used to perform save/restore related management of spooled files. When using a control group to save libraries with output queues, the control group attribute 'Save spooled file data' can be set to *ALL to save the spooled files when the output queues are saved. When these libraries or output queue objects are restored, the spooled files will also be restored if SPLFDTA(*NEW) is used with the restore.

If object level detail is retained or spooled lists are used to save spooled files, the Work with Saved Spooled Files using BRM (WRKSPLFBRM) command creates a display or report of saved spooled files based on specified libraries, output queues, files, job names, users, date ranges and sequences. Processing the Work with Saved Spooled Files command takes you to the Work with Saved Spooled Files display where you can remove, display or retrieve selected spooled file entries as well as work with media that contains saved spooled files.
Following are some of the commonly used commands for saving and restoring spooled files:
O
To save individual spooled files:
WRKSPLF
   Select Option 8 to note attributes of each spooled file you want to copy/save/restore.
CRTPF FILE(LibraryName/FileName) RCDLEN(133) MAXMBRS(#of_splfiles) SIZE(*NOMAX)
   This assumes that our spooled file is for a document that is 132 characters wide.
CPYSPLF FILE(SpooledFileName) TOFILE(LibraryName/PhysicalFileName) JOB(NNNNNN/UserName/JobName) SPLNBR(SSSS) TOMBR(MemberName) MBROPT(*ADD) CTLCHAR(*FCFC)
SAVOBJ OBJ(PhysicalFileName) LIB(LibraryName) DEV(OPTxx)
    If possible, make two copies on different devices.
To restore the spooled files saved in this way:
RSTOBJ OBJ(PhysicalFileName) SAVLIB(SavedLibraryName) FILEMBR(*ALL or MemberName) DEV(OPTxx)  RSTLIB(RestoreLibraryName)
OVRPRTF QSYSPRT CTLCHAR(*FCFC)
CPYF FROMFILE(RestoreLibraryName/PhysicalFileName) FROMMBR(MemberName) TOFILE(QSYSPRT)
O
To save an output queue:
SAVOBJ OBJ(OUTQNAME) LIB(OUTQLIB) DEV(OPTxx) OBJTYPE(*OUTQ) SPLFDTA(*ALL)
   This command will save the specific output queue with the spooled file data.
To restore an output queue:
RSTOBJ OBJ(OUTQNAME) SAVLIB(OUTQLIB) DEV(OPTxx) OBJTYPE(*OUTQ) SPLFDTA(*NEW)
   This command will restore the specific output queue and any new spooled files from that output queue that do not exist on the target system.
O
To save a library that contains output queues with spooled file data:
SAVLIB(QUSRSYS) DEV(OPTxx) SPLFDTA(*ALL)
   This command will save the entire QUSRSYS library including all spooled files.
To restore a library:
RSTOBJ OBJ(*ALL) SAVLIB(QUSRSYS) DEV(OPTxx) OBJTYPE(*OUTQ) SPLFDTA(*NEW)
   This command will restore all output queues and new spooled files from library QUSRSYS.

[{"Type":"MASTER","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"Platform":[{"code":"PF012","label":"IBM i"}],"Version":"7.1.0"}]

Historical Number

15432846

Document Information

Modified date:
28 December 2022

UID

nas8N1019635