Admin Alert: Creating a Save Changed Objects
March 9, 2005 Joe Hertvik
Like most operating systems, OS/400 provides a save changed objects function, allowing you to selectively backup only those objects that have changed since the last full system backup. This week, I’ll examine the save changed objects procedure and give you some simple CL code for creating a saved objects backup tape. A save changed object backup works in conjunction with a full system backup to minimize weekly backup times and to enable administrators to restore objects from several different tapes in a backup cycle.
The two backups work together in the following way:
- The full system or Save While Active backup creates a baseline portrait of your system that contains all user and system objects. It takes longer to backup a system this way, so this backup is generally run once a week when system usage is at its lowest.
- The save changed objects backup can be run on a regular basis to save only those objects that have been changed since the last full system backup. This type of backup runs faster–since there are far fewer files–and that means you can run it nightly and you can save changed objects while they are active.
When you need to restore objects to the system, you can restore them from either the full system backup tape or the save changed object tape or both, depending on which tape contains the version of the objects you want to restore. For libraries, you could restore the library from both tapes, overlaying the full backup with any newer objects from the save changed object tape. The result is that you have up-to-date backup coverage of all your user objects, without extending the time and resources it would take to back up every object every night.
Save changed object backups are also valuable when you’re migrating data from one AS/400, iSeries, or i5 partition to another. In a migration scenario, you may be staging and testing a new partition while you are still doing production work on an older partition on another machine. Using a save changed object tape in conjunction with a full backup, you can restore the entire system from the full backup tape, and then make the new box current at any time by only restoring those objects that have changed since the last full backup. A save changed object tape is also helpful in maintaining an independent test environment, where you periodically need to refresh your data with new information without having to reload the entire system.
To create a save changed objects tape that can be used to restore most user objects on an OS/400 system, I created the following code. With this code, you can create a tape that saves every user-based changed object that you might want to restore to a target system:
SAVSECDTA DEV(tape_drive_name) ENDOPT(*LEAVE) MONMSG MSGID(CPF0000) SAVCHGOBJ OBJ(*ALL) LIB(*ALLUSR) DEV(tape_drive_name) + OBJJRN(*YES) REFDATE(*SAVLIB) + ACCPTH(*YES) OUTPUT(*PRINT) MONMSG MSGID(CPF0000) SAVDLO DLO(*SEARCH) DEV(tape_drive_name) SRCHTYPE(*ALL) + OWNER(*ALL) REFCHGDATE(*SAVDLOALL) MONMSG MSGID(CPF0000) SAV DEV(/QSYS.LIB/tape_drive_name.DEVD) OBJ(('/*' *INCLUDE) + ('/QSYS.LIB' *OMIT) ('/QDLS' *OMIT)) + OUTPUT(*PRINT) ENDOPT(*LEAVE) + CHGPERIOD(*LASTSAVE)
Except for the Save Security Data (SAVSECDTA) command, all these commands can also be run in Save While Active mode. Here’s how it all fits together.
The SAVSECDATA command saves all user profiles that you may need to restore to your target system. There is nothing different about this command that you wouldn’t see in a regular full system or Save While Active backup, but you can use this function to keep your security data current.
As shown here, the Save Changed Objects command (SAVCHGOBJ) saves all the changed objects in your machine’s user libraries (all libraries whose names do not begin with the letter ‘Q’) as designated by *ALLUSR literal in the Library parameter (LIB). By designating *SAVLIB in the Reference Date parameter (REFDATE), OS/400 only saves those objects that have changed in your libraries since the last time a SAVLIB command was run over each library.
If you want to modify this SAVCHGOBJ command to only backup objects that have changed since a certain date and time, you could change the command to look like this:
SAVCHGOBJ OBJ(*ALL) LIB(*ALLUSR) DEV(tape_drive_name) + OBJJRN(*YES) REFDATE('mm/dd/yy') + REFTIME('hh:mm:ss') ACCPTH(*YES) + OUTPUT(*PRINT)
Running the command this way only saves those objects that were changed after the date and time specified in the Reference Date and Reference Time parameters (REFDATE and REFTIME, respectively). This variation is handy when you are trying to synchronize data between two environments, where the synchronizing partition was originally restored from a full system backup and you want to create a tape to port newer object changes between the two environments.
The Save Document Library Object command (SAVDLO) performs the same function for Document Library Objects (DLOs) as the SAVCHGOBJ command does for OS/400 library objects. In this configuration, SAVDLO will only save DLO folder and document objects that have been created since the last time the SAVDLO command was run, as specified by the *SAVDLOALL value in the Last Changed Date parameter (REFCHGDATE). Note that you can only save changed DLOs when the DLO parameter (DLO) is equal to *SEARCH.
Like the SAVCHGOBJ command, you can also tell the SAVDLO command to only save files that have been saved since a certain date and time by entering the starting date and time in the Last Changed Date (REFCHGDATE) and the Last Changed Time (REFCHGTIME) parameters.
The Save command (SAV) saves all the IFS objects that have changed since the last time the SAV command was run with the Update History parameter (UPDHST) set to *YES. (This is specified by setting the time period for last change parameter, CHGPERIOD, to *LASTSAVE in the code above). Like the other commands, the CHGPERIOD parameter can also be set to save IFS objects that were modified after a specific date and time.
With these commands, you can create a save changed objects tape that contains all the non-IBM objects that you might need to restore changed files to your current system or to a system in another environment. But just remember that this tape has to work in conjunction with a recent system backup or it will not be as helpful to your shop.
Click here to contact Joe Hertvik by e-mail.