bvstone

Performing IBM i (AS400, iSeries, System i) Backups using Google Drive

Posted:

Performing IBM i (AS400, iSeries, System i) Backups using Google Drive

Recently we released the Google Drive Addon (G4GGDRV) for GreenTools for Google Apps (G4G).  

We did this because we wanted an easier way to perform backups on our IBM i using "the cloud".  Because we use Google for our business we have plenty of space for backing up our data.

Really there's nothing different to this than saving to tape, except we add a few extra steps.

Here's the CL Source code we use for this:

             PGM
             DCLF       FILE(BACKUPPF)
             DCL        VAR(&FILEN) TYPE(*CHAR) LEN(128)
             DCL        VAR(&ZIPFILE) TYPE(*CHAR) LEN(128)
             DCL        VAR(&IFSDIR) TYPE(*CHAR) LEN(128)
             DCL        VAR(&SAVEF) TYPE(*CHAR) LEN(128)
             DCL        VAR(&IFSSAVEF) TYPE(*CHAR) LEN(128)
             DCL        VAR(&FQZIP) TYPE(*CHAR) LEN(128)
             DCL        VAR(&CMD) TYPE(*CHAR) LEN(128)

READ:
             RCVF
             MONMSG     MSGID(CPF0000) EXEC(GOTO CMDLBL(END))

             CHGVAR     VAR(&FILEN) VALUE(&NAME *TCAT '.savf')
             CHGVAR     VAR(&ZIPFILE) VALUE(&NAME *TCAT '.zip')
             CHGVAR     VAR(&IFSDIR) VALUE('/backups')
             CHGVAR     VAR(&SAVEF) VALUE('/qsys.lib/qgpl.lib/' +
                          *TCAT &NAME *TCAT '.file')
             CHGVAR     VAR(&IFSSAVEF) VALUE(&IFSDIR *TCAT '/' *TCAT +
                          &FILEN)
             CHGVAR     VAR(&FQZIP) VALUE(&IFSDIR *TCAT '/' *TCAT +
                          &ZIPFILE)

             CRTSAVF    FILE(BVSTONEO/&NAME)
             MONMSG     MSGID(CPF0000)

             CLRSAVF    FILE(BVSTONEO/&NAME)

             IF         COND(&TYPE *EQ 'lib') THEN(DO)
             SAVLIB     LIB(&NAME) DEV(*SAVF) SAVF(BVSTONEO/&NAME) +
                          CLEAR(*ALL) SAVACT(*LIB)
             MONMSG     MSGID(CPF0000)
             ENDDO

             IF         COND(&TYPE *EQ 'ifs') THEN(DO)
             SAV        DEV(&SAVEF) OBJ((&PATH)) SUBTREE(*ALL) +
                          SAVACT(*YES)
             MONMSG     MSGID(CPF0000)
             ENDDO

             CPYTOSTMF  FROMMBR(&SAVEF) TOSTMF(&IFSSAVEF) +
                          STMFOPT(*REPLACE) STMFCODPAG(819)
             MONMSG     MSGID(CPF0000)

             CHGVAR     VAR(&CMD) VALUE('cd /backups; jar -cf' *BCAT +
                          &ZIPFILE *BCAT &SAVEF)
             QSH        CMD(&CMD)
             MONMSG     MSGID(CPF0000)

             G4GUPLOAD  ID(xxx@xxx.xxx) STMF(&FQZIP) +
                          TOFLR('/MyPath/AS400 Stuff/Backups')
             MONMSG     MSGID(CPF0000)

             GOTO       CMDLBL(READ)

END:

             ENDPGM

First, we have a file named BACKUPPF with the following layout:

File Name . . . . BACKUPPF                            
  Library . . . .   FILELIB
Format Descr  . .                                     
Format Name . . . RBACKUP    
File Type . . . . PF            Unique Keys - N 
                                                      
Field Name FMT Start Lngth Dec Key Field Description  
TYPE        A      1    10         Save Type          
NAME        A     11    10         Library Name       
PATH        A     21   128         IFS Path           

TYPE is the type of file(s) to backup.  This is either a library or ifs object.

NAME is the name of the library and/or save file we will use (minus any extension).

PATH is the path we want to save if this is an IFS object.

The first thing our CL does is read in the first record.  If there is no error, it builds a few variables that will be used throughout the program.  

FILEN is used to hold the filename and .savf extension of our save file.  ZIPFILE is the name of the file after it is zipped (using JAR and QSHELL).  IFSDIR defines the directory in the IFS that we will be placing the files.  SAVEF is the fully qualified path to the save file, using the IFS naming convention.  FQZIP is the Fully Qualified path and name of the zip file that we will end up uploading to our Google Drive.

Next, we check the object type to save.  Depending on if it is a library or IFS location, we run the appropriate SAVLIB or SAV command.

Once we have a save file, we copy that to the IFS using the CPYTOSMTF command.

Next we use QSHELL and the JAR command to compress the save file.  JAR and ZIP use pretty much the same algorithm so there's really no need for an extra ZIP package.

Finally, we call the G4GUPLOAD command, which is part of the Google Drive Addon for G4G, and upload the ZIP file to the appropriate location on our Google Drive.

Fairly simple and very functional.  You could even combine this with the the Google Calendar Addon to fire off this backup job daily, weekly, or whenever you want.  The possibilities are really endless.


Last edited 02/08/2015 at 14:33:31



Latest Posts:

MAILTOOL Errors with Microsoft Office 365 (2020) MAILTOOL Errors with Microsoft Office 365 (2020)
Posted by September 3, 2020
BVSTools >> BVSTools Software Discussion >> Email Tools (MAILTOOL) Specific Discussion
Using MAILTOOL With Office 365 and Two Factor Authentication (2FA or MFA) Using MAILTOOL With Office 365 and Two Factor Authentication (2FA or MFA)
Posted by August 17, 2020
BVSTools >> BVSTools Software Discussion >> Email Tools (MAILTOOL) Specific Discussion
Updating DNS With Dynamic IP Addresses After a Router Reboot/Power Outage Updating DNS With Dynamic IP Addresses After a Router Reboot/Power Outage
Posted by August 16, 2020
Programming >> Proof of Concept (POC)
GETURI v10.10 Released with New ILE Functions GETURI v10.10 Released with New ILE Functions
Posted by August 12, 2020
BVSTools >> BVSTools Announcements >> Get URI (GETURI) Specific Announcements
MAILTOOL Updated to Allow G4GSMAIL as Option in Routers File MAILTOOL Updated to Allow G4GSMAIL as Option in Routers File
Posted by June 28, 2020
BVSTools >> BVSTools Announcements >> eMail Tool (MAILTOOL) Specific Announcements
BVSTools Now Offers Interface with Infor's ION APIs BVSTools Now Offers Interface with Infor's ION APIs
Posted by May 15, 2020
BVSTools >> BVSTools Announcements
More V7R4 IFS File CCSID Issues and The Fix More V7R4 IFS File CCSID Issues and The Fix
Posted by March 4, 2020
IBM Power Systems >> (QGPL) IBM i
Error Retrieving IP Address by Name Error Retrieving IP Address by Name
Posted by February 25, 2020
BVSTools >> BVSTools Software Discussion
Logging jobs that hit an outq Logging jobs that hit an outq
Posted by February 13, 2020
Programming >> CL Programming
GreenTools for Google Apps (G4G) v12.60 Released with Shared Drive Features and More... GreenTools for Google Apps (G4G) v12.60 Released with Shared Drive Features and More...
Posted by February 4, 2020
BVSTools >> BVSTools Announcements >> GreenTools for G Suite (Google Apps) (G4G) Specific Announcements
Allowing Requests over Port 80 For SSL Validation (ie, Namecheap, etc) Allowing Requests over Port 80 For SSL Validation (ie, Namecheap, etc)
Posted by January 31, 2020
Programming >> Web Programming
GreenTools for Slack (G4SLK) v3.00 Released GreenTools for Slack (G4SLK) v3.00 Released
Posted by January 17, 2020
BVSTools >> BVSTools Announcements >> GreenTools for Slack (G4SLK) Specific Announcements
Calling a QSH Command from RPG Calling a QSH Command from RPG
Posted by December 26, 2019
Programming >> RPG Programming
SPLTOOL Print Range (PRTRNG) Function Updated to Handle Spooled Files up to 999,999,999 Pages SPLTOOL Print Range (PRTRNG) Function Updated to Handle Spooled Files up to 999,999,999 Pages
Posted by December 14, 2019
BVSTools >> BVSTools Announcements >> Spooled File Tools (SPLTOOL) Specific Announcements
GreenTools for Microsoft Apps (G4MS) Updated to v6.00 - Now Uses Microsoft Graph APIs GreenTools for Microsoft Apps (G4MS) Updated to v6.00 - Now Uses Microsoft Graph APIs
Posted by November 24, 2019
BVSTools >> BVSTools Announcements >> GreenTools for Microsoft Apps (G4MS) Specific Announcements

Reply




Copyright 1983-2020 BVSTools
GreenBoard(v3) Powered by the eRPG SDK, MAILTOOL Plus!, GreenTools for Google Apps, jQuery, jQuery UI, BlockUI, CKEditor and running on the IBM i (AKA AS/400, iSeries, System i).