• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • API Corner: Backup APIs

    November 16, 2005 Shannon O'Donnell

    The code for this article is available for download.

    In this issue of API Corner, I am going to show you how to use some of the Backup APIs, which you can then use to programmatically determine when certain objects, such as libraries and files, were last backed up. Specifically, I will cover the Backup History, Backup Detail, and the Backup Schedule APIs.

    The Backup APIs

    The Backup and Recovery APIs make working with backup information much easier than trying to use *OUTFILES from such IBM commands as DSPOBJD (Display Object Description). When you use the backup APIs, you can do away with all that *OUTFILE nonsense and in the process gain much tighter control over your system.

    For this article, I’ve created a menu program, BACKUPMC1, which has three options:

    1. Backup History
    2. Backup Detail
    3. Backup Schedule

    The Backup History option uses the QEZRTBKH (Retrieve Backup History) API to retrieve information about the status and history of the entire system.

    The Backup Detail option uses the QEZRTBKD (Retrieve Backup Detail) API to retrieve information about a specific library or QDLS Folder.

    The Backup Schedule API uses the QEZRTBKS (Retrieve Backup Schedule) API to retrieve the system backup schedule.

    QEZRTBKH

    Your programs can use the Retrieve Backup History API can be used by your program to retrieve the system backup history. Of course, you can also use the DSPBCKSTS (Display Backup Status) command to push this same information to the screen or to a printer file, but that is not very useful if you need to have your program make some decisions about what to do about something based on when the system was last backed up. The much better alternative is to use the QEZRTBKH API.

    The sample program included with this article that uses this API is named BACKUPR2. To use the QEZRTBKH API you only need to pass it a receiver variable to store the backup history in, a variable that defines the length of the receiver variable, the format name of the API and the standard Error Data Structure I’ve been using in all the other programs in the API Corner series.

    * Retrieve Backup History
    C                   Call      'QEZRTBKH'
    C                   Parm      *Blanks       RcvrVar
    C                   Parm      261           RcvrVarLen
    C                   Parm      'RBKH0100'    Format
    C                   Parm                    dsEc
     *
    

    The format of the returned information is determined by the format you choose for this API. The RBKH0100 Format will return the least amount of information, while the RBKH0200 Format will return more. For our purposes, we will use the RBKH0100 Format:

    D RBKH0100        DS
    D  BytAvl                       10i 0
    D  BytRtn                       10i 0
    D  LDatAULib                     7a
    D  LTimAULib                     6a
    D  TapSetAULib                   4a
    D  LDatAULibC                    7a
    D  LTimAULibC                    6a
    D  TapSetAULibC                  4a
    D  LDatLbLst                     7a
    D  LTimLbLst                     6a
    D  TapSetLbLst                   4a
    D  LDatLbLstC                    7a
    D  LTimLbLstC                    6a
    D  TapSetLbLstC                  4a
    D  LDatFlr                       7a
    D  LTimFlr                       6a
    D  TapSetFlr                     4a
    D  LDatFlrC                      7a
    D  LTimFlrC                      6a
    D  TapSetFlrC                    4a
    D  LDatFlrLs                     7a
    D  LTimFlrLs                     6a
    D  TapSetFlrLs                   4a
    D  LDatSecDta                    7a
    D  LTimSecDta                    6a
    D  TapSetSecDta                  4a
    D  LDatCfgDta                    7a
    D  LTimCfgDta                    6a
    D  TapSetCfgDta                  4a
    D  LDatCalDta                    7a
    D  LTimCalDta                    6a
    D  TapSetCalDta                  4a
    D  LDatMalDta                    7a
    D  LTimMalDta                    6a
    D  TapSetMalDta                  4a
    D  LDatUsrDir                    7a
    D  LTimUsrDir                    6a
    D  TapSetUsrDir                  4a
    D  LDatUsrDirC                   7a
    D  LTimUsrDirC                   6a
    D  TapSetUsrDirC                 4a
    D  Rsvd21                       21a
    

    There is a lot of information in the format, but most of it repeats, which makes it a lot easier to work with. When you call the API, the backup history will be returned into the receiver variable. You can use this returned information in whatever way best fits your needs, such as kicking off another system backup only when a certain amount of time has passed since the last backup. The rest of the sample program is fairly straightforward, pushing the returned information to the display screen.

    QEZRTBKD

    Use the Retrieve Backup Detail API to retrieve the system backup history. This API is similar to the information you can get by using the DSPOBJD, DSPFD, DSPLIB commands, but again, it is much easier to use data returned from the API directly into your RPG program than it is to try to read it off of a printed report or an *OUTFILE.

    The sample program included with this article that uses this API is named BACKUPR1. To use the QEZRTBKD API, pass a receiver variable to store the backup history in, a variable that defines the length of the receiver variable, the name of the object you want to check the backup history of, the length of that object name, the format name of the API, the type of object you want to check and the standard Error Data Structure.

    C                   Call      'QEZRTBKD'
    C                   Parm      *Blanks       RcvrVar
    C                   Parm      84            RcvrVarLen
    C                   Parm      InObj         Objname
    C                   Parm      LenObjName    ObjNameLen
    C                   Parm      'RBKD0100'    Format
    C                   Parm                    ObjType
    C                   Parm                    dsEc
    

    Since there is only a single format available for this API, you don’t need to decide which one to use. Here is the layout for the returned for format RBKD0100:

    D RBKD0100        DS
    D  BytAvl                       10i 0
    D  BytRtn                       10i 0
    D  LstSavDat                     7a
    D  LstSavTim                     6a
    D  ObjDesc                      50a
    D  ChgSncLstBk                   1a
    

    The information returned is fairly minimal, but again, if you need to make a decision in a program based on some backup information, then it’s very nice and convenient to be able to retrieve that data into a variable in your RPG program.


    QEZRTBKS

    The Retrieve Backup Schedule API can be used by your program to retrieve the system backup schedule. The information returned in this API is exactly the same as the information you can get by using the Change Backup Schedule option from the system BACKUP (Go Backup) menu. Again, however, it is much more convenient to be able to retrieve this information into a program variable than it is to try to parse it from a display screen.

    The sample program included with this article that uses this API is named BACKUPR3. To use the QEZRTBKS API, you need to pass it a receiver variable to store the backup history in, a variable that defines the length of the receiver variable, the format name of the API, and the standard Error Data Structure.

    * Retrieve Backup History
                       Call      'QEZRTBKS'
                       Parm      *Blanks       RcvrVar
                       Parm      261           RcvrVarLen
                       Parm      'RBKS0100'    Format
                       Parm                    dsEc
    

    Since there is only a single format available for this API, you don’t need to decide which one to use. Here is the layout for the returned for format RBKS0100:

    D RBKS0100        DS
    D  BytAvl                       10i 0
    D  BytRtn                       10i 0
    D  RHOUR                        10i 0
    D  ROCCUR                       10i 0
    D  RRUN                          1a
    D  RSUN                          1a
    D  RSUNT                         6a
    D  RMON                          1a
    D  RMONT                         6a
    D  RTUE                          1a
    D  RTUET                         6a
    D  RWED                          1a
    D  RWEDT                         6a
    D  RTHU                          1a
    D  RTHUT                         6a
    D  RFRI                          1a
    D  RFRIT                         6a
    D  RSAT                          1a
    D  RSATT                         6a
    

    You can use the returned information from this API along with the QEZCHBKS (Change Backup Schedule) API to programmatically change the system backup schedule based on some user defined criteria.

    Backup Information at Your Fingertips!

    The Backup APIs discussed in this article and included as downloadable code are only the tip of the iceberg as far as Backup and Recovery APIs go. There is a veritable cornucopia stuffed with Backup and Recovery functions that you can use from within your applications, which until now you probably thought were only available by using IBM-supplied commands. Check out the online IBM Information Center for more details.

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    WorksRight Software

    Do you need area code information?
    Do you need ZIP Code information?
    Do you need ZIP+4 information?
    Do you need city name information?
    Do you need county information?
    Do you need a nearest dealer locator system?

    We can HELP! We have affordable AS/400 software and data to do all of the above. Whether you need a simple city name retrieval system or a sophisticated CASS postal coding system, we have it for you!

    The ZIP/CITY system is based on 5-digit ZIP Codes. You can retrieve city names, state names, county names, area codes, time zones, latitude, longitude, and more just by knowing the ZIP Code. We supply information on all the latest area code changes. A nearest dealer locator function is also included. ZIP/CITY includes software, data, monthly updates, and unlimited support. The cost is $495 per year.

    PER/ZIP4 is a sophisticated CASS certified postal coding system for assigning ZIP Codes, ZIP+4, carrier route, and delivery point codes. PER/ZIP4 also provides county names and FIPS codes. PER/ZIP4 can be used interactively, in batch, and with callable programs. PER/ZIP4 includes software, data, monthly updates, and unlimited support. The cost is $3,900 for the first year, and $1,950 for renewal.

    Just call us and we’ll arrange for 30 days FREE use of either ZIP/CITY or PER/ZIP4.

    WorksRight Software, Inc.
    Phone: 601-856-8337
    Fax: 601-856-9432
    Email: software@worksright.com
    Website: www.worksright.com

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    IBM Unveils New Midrange Storage Systems QlikTech Targets iSeries Base with Business Intelligence App

    Leave a Reply Cancel reply

Volume 5, Number 43 -- November 16, 2005
THIS ISSUE
SPONSORED BY:

T.L. Ashford
Advanced Systems Concepts
WorksRight Software

Table of Contents

  • API Corner: Backup APIs
  • Two Handy Programs
  • Admin Alert: Darn Good FTP Commands You’ve Probably Never Heard Of

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • IBM i Has a Future ‘If Kept Up To Date,’ IDC Says
  • When You Need Us, We Are Ready To Do Grunt Work
  • Generative AI: Coming to an ERP Near You
  • Four Hundred Monitor, March 22
  • IBM i PTF Guide, Volume 25, Number 12
  • Unattended IBM i Operations Continue Upward Climb
  • VS Code Is The Full Stack IDE For IBM i
  • Domino Runs on IBM i 7.5, But HCL Still Working on Power10
  • Four Hundred Monitor, March 6
  • IBM i PTF Guide, Volume 25, Number 11

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2023 IT Jungle