Friday, February 19, 2016

Taking an Entire System Backup in AS/400 Machine

Admin Alert: Dissecting an Option 21 Save

by Joe Hertvik
Being a complicated and robust system, OS/400 offers several different save and restore commands for backup protection of different system components. Unfortunately, this wealth of options sometimes gets confusing, and it's helpful to understand how the pieces of the puzzle fit together. To that end, let's take a few minutes to look at the different components of a typical OS/400 full system backup and how they relate to one another.
The classic full system backup is performed by selecting Option 21 (Entire System) from the GO SAVE menu. (Note: Option 21 must be run from the system console.) Here's a breakdown of all the steps Option 21 uses to save your system data to media and how you can use selected restore commands to bring back subsets of the data.
Step 1
Option 21 puts the system into restricted state by using the End Subsystem (ENDSBS) command, as follows:
ENDSBS SBS(*ALL) OPTION(*IMMED)
The ENDSBS command shuts down all your iSeries or AS/400 subsystems, leaving only the system console active for you to perform backups or other restricted system chores on. (For more information on restricted state and how ENDSBS works, see "Admin Alert: Getting In and Out of iSeries Restricted State.")
Step 2
Change the QSYSOPR message queue to break or notify mode, for viewing tape drive messages as your system is being backed up. Besides prompting for the proper tape drive to which your system would back up, Option 21 prompts you to automatically display or notify you of operator messages that occur during your backup. Depending on how you answer the prompts, Option 21 will use one of the following Change Message Queue (CHGMSGQ) commands, to change the QSYSOPR message to *BREAK or *NOTIFY mode for your job.
CHGMSGQ  QSYSOPR  DLVRY(*BREAK) 
Or
CHGMSGQ  QSYSOPR  DLVRY(*NOTIFY)
Step 3
Save system and user configuration data by using the Save System (SAVSYS) command. This command saves three sets of data to your backup media: OS/400 licensed internal code and OS/400 objects in the QSYS library; security data, which includes user profiles and private authorities; and configuration objects. Outside of Option 21, you could save your system's security data separately by using the Save Security Data (SAVSECDTA) command. To restore OS/400 security data from media, use the Restore User Profiles (RSTUSRPRF) command for user profiles and the Restore Authority (RSTAUT) command for private authorities. The configuration object save backs up the same configuration data as the Save Configuration (SAVCFG) command, and you would use the Restore Configuration (RSTCFG) command to restore that data back to the system.
Step 4
Option 21 saves all libraries by using the Save Library (SAVLIB) command with the *NONSYS option, as follows:
SAVLIB LIB(*NONSYS) DEV(tape_drive_name) ACCPTH(*YES)
Using the *NONSYS parameter is equivalent to running the following two SAVLIB statements together, and by using SAVLIB *NONSYS, Option 21 saves both sets of data at one time.
SAVLIB LIB(*IBM) DEV(tape_drive_name)

SAVLIB LIB(*ALLUSR) DEV(tape_drive_name)
*IBM libraries include all OS/400 optional libraries--such as QHLPSYS and QUSRTOOL--as well as your licensed program libraries. *ALLUSR libraries include any IBM library that contains user data--including QGPL, QUSRSYS, and several libraries that start with the number sign (#)--and all non-IBM libraries. In the event of a complete system restore, you could recover all your *IBM or *ALLUSR libraries by using the Restore Library (RSTLIB) command with the *NONSYS option, as follows:
RSTLIB LIB(*NONSYS) DEV(tape_drive_name)
Or you could restore just the *IBM libraries or the *ALLUSR libraries by using either of the following commands:
RSTLIB  LIB(*IBM) DEV(tape_drive_name)

RSTLIB  LIB(*ALLUSR) DEV(tape_drive_name)
More commonly, however, you would restore one specific library by using the following RSTLIB command:
RSTLIB  LIB(lib_name) DEV(tape_drive_name)
Step 5
Save all OS/400-based document library objects and distribution objects by using the following Save Document Library Object (SAVDLO) command:
SAVDLO  DLO(*ALL) SAVFLR(*ANY) DEV(tape_drive_name)
Any of these objects can be restored by using the Restore Document Library Object (RSTDLO) command.
Step 6
Option 21 saves all Integrated File System (IFS) data--except for the QSYS.LIB and the QDLS file systems, which are backed up through the other SAVxxx commands listed in the previous steps--by using the Save Object (SAV) command:
SAV DEV('/QSYS.LIB/tape-device-name.DEVD) +
OBJ(('/')  ('/QSYS.LIB' *OMIT) ('/QDLS' *OMIT))+
UPDHST(*YES)
This command saves all IBM-supplied IFS directories and user data sitting in non-OS/400-based directories. To restore any IFS directory or object, you would use the Restore Object (RST) command.
Step 7
Restart your system by starting the controlling subsystem, with the following Start Subsystem (STRSBS) command:
STRSBS  SBSD(controlling_subsystem_name)
When you start the controlling subsystem, the subsystem also starts the OS/400 startup program (as defined in the Startup Program system value, QSTRUPPGM), taking your system out of restricted state.
By following these seven steps, your Option 21 backup has taken a fairly complete picture of your system that can be used to reload the system to another machine for disaster recovery or to restore selected pieces of a configuration at will. Each save command also provides information about the number of objects backed up and--more important--the number of objects that weren't backed up.
In addition to running your full system backup in its original "virgin" form, you can retrieve the Option 21 source code and modify it to run different features, programs, or commands during a full system save. Option 21 calls a CL program called QMNSAVE, which usually resides in library QSYS. You can use the Retrieve CL Source (RTVCLSRC) command to obtain a copy of the source code, change it to add your own extensions, and then recompile it back to its original location. If you do this, you may want to save a copy of the original QMNSAVE object and source code for possible restoration, in case you make a mistake or want to back out of your changes.
Finally, pictures are always helpful in explaining processes such as Option 21, and I found a great graphic for explaining most of OS/400's save and restore options in--of all places--an IBM sales brochure. This brochure contains a beautifully concise chart showing all your iSeries save and restore options using OS/400 green-screen save and restore commands. It even has a second graphic showing all your Backup, Recovery and Media Services for AS/400 (BRMS/400) options. If you're responsible for backup and disaster recovery in your shop, it's worth downloading this PDF file and filing it away for future reference.

source from  http://www.itjungle.com/tfh/tfh082602-story04.html