Admin Alert: Hidden Secrets of the i5/OS Save Commands
November 2, 2005 Joe Hertvik
How well do you know your OS/400 and i5/OS backup commands? Did you know that there are a number of lesser known backup parameters that enable backup operations to run faster, protect media during its retention cycle, specify date ranges for backing up changed data, and provide valuable information on your backup operation? This week, let’s look at some underused backup parameters and how they can make your life easier.
Most of the parameters I’ll discuss here are included in IBM‘s SAVxxx commands that control i5/OS and OS/400 backup operations. These commands include the two Save Object commands (SAV and SAVOBJ), as well as the Save Library (SAVLIB), and Save Document Library Object (SAVDLO) commands. The more valuable but overlooked parameters that you might want to check out for these commands are the following:
Clear (CLEAR): This parameter specifies whether any active files saved on the target media are automatically cleared. The default is *NONE, which tells i5/OS not to automatically clear live data. If media with live data is put into the drive, the operating system will send an inquiry message to the operator message queue asking whether the media should be cleared or whether the operation should be ended. If CLEAR is set to *ALL, any media loaded up for this backup operation will automatically be cleared. Setting CLEAR to *AFTER is a hybrid operation, where the operator is prompted as to whether the first media should be cleared and–if she says yes–not only is the first media cleared, but all subsequent media are automatically cleared after that. The final option you can set CLEAR to is *REPLACE, where all active files on the first media are automatically replaced (but not cleared) and all subsequent media used in the backup operation are then automatically cleared.
File Expiration Date (EXPDATE): Placing a date in this field protects your media from being overridden before the entered date. If you try to reuse the media before the expiration date occurs, the files will be protected by OS/400 and cannot be overwritten. This feature is useful for enforcing media retention schedules during a backup. You can perform your backup within a CL program, have the program calculate the expiration date based on your retention policy, and mark the media with that new retention date during the SAVxxx command. There is one gotcha, however. While marking your media with an expiration date will prevent files from automatically being overwritten with a SAVxxx command, it will not protect the media if a backup is performed when the Clear (CLEAR) parameter is set to *ALL or a tape is initialized through the Initialize Tape command (INZTAP) before the backup begins.
End of Media option (ENDOPT): This parameter is used to tell the SAVxxx operation what to do with the media after the backup operation ends. There are three options: *REWIND, *LEAVE, and *UNLOAD. *REWIND (the default) tells i5/OS to rewind tape media to the beginning of the tape when the SAVxxx option ends. While some people think that this means that existing tape files will be overwritten if another backup operation begins while a tape from a prior backup is in the drive, it does not. Unless the next backup operation starts after the tape is reinitialized or cleared through the CLEAR parameter, a subsequent backup operation will first search the tape for the last backup set written, and then it will direct the new backup operation to write directly to the tape after the last existing set.
To get around the delay caused by running two SAVxxx operations in a row with the ENDOPT parameter set to *REWIND, you can set ENDOPT to *LEAVE. *LEAVE tells i5/OS to leave the tape in the ready position at its existing location when the backup ends. By doing this, a subsequent SAVxxx command will start backing up immediately to tape without having to first find the next available backup set, as it needs to do when ENDOPT is set to *REWIND.
The last ENDOPT parameter is *UNLOAD, which tells i5/OS to automatically unload the tape after the SAVxxx command is complete. You should generally use *UNLOAD for situations where all backup operations are complete for this tape and you don’t want to add any more items to the tape.
Target Release (TGTRLS): This parameter is useful in backing up objects that will be restored to a prior OS/400 version on a different machine or partition. For every OS/400 version, there are specific earlier target release formats that files can be saved to. For i5/OS V5R3, objects can be saved in i5/OS V5R2M0 or V5R1M0 formats but the format lists are different for each operating system version. You can specify the file should be saved in the operating system release that is currently running on the system by entering *CURRENT (its default) in the TGTRLS parameter. By entering *PRV, you can tell your SAVxxx command to save the file in the format of the last zero modification level release (V5R2M0 for i5/OS V5R3M0) of the operating system. You can also specify the exact format to save the files to in this parameter (ex, V5R2M0 or V5R1M0).
Time period for last change (CHGPERIOD): This option is only available on the Save Object (SAV) command, and it allows you to specify starting and ending dates and times for objects that will be saved. When the command processes your backup criteria, it will only save objects that were changed within the time period specified in the CHGPERIOD parameter. You can also specify *ALL for this parameter (the default) which saves all files meeting your criteria, regardless of when they were last modified. *ALL does this by telling i5/OS to ignore the starting date and time, and save any objects that were modified anytime before the current end date and time. When CHGPERIOD is set to *LASTSAVE, the command will back up any specified object that was changed since the last time those objects were saved. *LASTSAVE requires that the SAV command’s Update history parameter (UPDHST) be set to *YES.
Object Pre-Check (PRECHK): This parameter is used to ensure that a complete backup occurs without skipping any objects. If you set PRECHK to *YES, it will check to see whether all the specified objects in your backup can be saved and–if they cannot all be saved–the SAVxxx command will end without saving any objects at all. There are a number of conditions the commands will pre-check objects for, including objects that do not exist; libraries or objects that are damaged; libraries or objects that are locked by another job; and whether or not the user running the SAVxxx command has authority to the objects or the authority to save the objects. For situations where a complete backup is essential, this parameter can come in very handy. The default is *NO, which means that the SAVxxx operation does not perform any pre-checking before the backup.
Create an output list with information about your SAVxxx operation by using the Output parameter (OUTPUT) in coordination with the Type of output information parameter (INFTYPE): You can use the OUTPUT parameter to tell the command to capture and output information about the backup operation to either a printout (when set to *PRINT) or to a database file (when set to *OUTFILE).
The *OUTFILE option is not available on the SAV command. When capturing information to a database file, you must also specify the file to receive the save output in the File to receive output parameter (OUTFILE). The default OUTPUT value is *NONE. You also have a choice of what types of information to save by specifying a value in the INFTYPE parameter. The default value for INFTYPE is *OBJ, which produces a line of output for every object that the backup operation tried to save. *OBJ can produce an extremely large file, depending on your backup operation, so a more practical approach might be to set INFTYPE to *ERR. *ERR logs information about the command itself, each library the command attempted to backup, and an entry for each object that was unsuccessfully backed up. Using *ERR produces an exception report of problems with the backup operation, and this report is much more valuable for quickly spotting problems with the backup. The other INFTYPE values are *LIB and *MBR, which produce lists of library entries that were requested to be saved and members requested to be saved, respectively. But these output entries are generally less valuable than the output produced when INFTYPE is set to *ERR or *OBJ.
Sometimes you can teach a backup new tricks, and using some of these parameters can provide more flexibility and efficiency to your i5/OS backup operations.