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:

BVSTools is Now Running V7R4M0 BVSTools is Now Running V7R4M0
Posted by September 28, 2019
BVSTools >> BVSTools Announcements
GreenTools for G Suite (G4G) Now Includes Send Mail Functionality (G4GSMAIL Addon) GreenTools for G Suite (G4G) Now Includes Send Mail Functionality (G4GSMAIL Addon)
Posted by August 27, 2019
BVSTools >> BVSTools Announcements >> GreenTools for G Suite (Google Apps) (G4G) Specific Announcements
GreenTools For G Suite (G4G) v12.00 Released With Base OAuth 2.0 Functionality GreenTools For G Suite (G4G) v12.00 Released With Base OAuth 2.0 Functionality
Posted by July 28, 2019
BVSTools >> BVSTools Announcements >> GreenTools for G Suite (Google Apps) (G4G) Specific Announcements
BVSTools Small Price Increase in 2020 BVSTools Small Price Increase in 2020
Posted by July 26, 2019
BVSTools >> BVSTools Announcements
GreenTools for Vertex Cloud (VTXCLOUD) Now Available GreenTools for Vertex Cloud (VTXCLOUD) Now Available
Posted by July 22, 2019
BVSTools >> BVSTools Announcements >> GreenTools for Vertex Cloud (VTXCLOUD) Specific Announcements
GreenTools for Google Apps (G4G) - Drive Addon Successfully Verified by Google GreenTools for Google Apps (G4G) - Drive Addon Successfully Verified by Google
Posted by July 22, 2019
BVSTools >> BVSTools Announcements >> GreenTools for G Suite (Google Apps) (G4G) Specific Announcements
Why I Cancelled my DynDNS Service and How I Replaced It with an IBM i Application Why I Cancelled my DynDNS Service and How I Replaced It with an IBM i Application
Posted by July 17, 2019
IBM Power Systems >> (QGPL) IBM i
Green Tools for G Suite (G4G) Product Updates (Licensing, Functionality, Base Product) Green Tools for G Suite (G4G) Product Updates (Licensing, Functionality, Base Product)
Posted by July 13, 2019
BVSTools >> BVSTools Announcements >> GreenTools for G Suite (Google Apps) (G4G) Specific Announcements
Reading JSON Data from Standard Input With YAJL and RPG Reading JSON Data from Standard Input With YAJL and RPG
Posted by July 12, 2019
Programming >> Proof of Concept (POC)
MAILTOOL Updated to Allow Use of IBM Global Security Kit (GSKIT) for SSL/TLS Communications MAILTOOL Updated to Allow Use of IBM Global Security Kit (GSKIT) for SSL/TLS Communications
Posted by June 19, 2019
BVSTools >> BVSTools Announcements >> eMail Tool (MAILTOOL) Specific Announcements
GETURI v10.00 Released Supporting IBM Global Security Kit (GSKIT) and Server Name Indication (SNI) GETURI v10.00 Released Supporting IBM Global Security Kit (GSKIT) and Server Name Indication (SNI)
Posted by June 11, 2019
BVSTools >> BVSTools Announcements >> Get URI (GETURI) Specific Announcements
BVSTools Now Offers Vertex Cloud Interface BVSTools Now Offers Vertex Cloud Interface
Posted by April 15, 2019
BVSTools >> BVSTools Announcements
Token Has an Invalid Signature Error for Office 365 Email Token Has an Invalid Signature Error for Office 365 Email
Posted by March 22, 2019
BVSTools >> BVSTools Software Discussion >> GreenTools for Microsoft Apps (G4MS) Specific Discussion
Resending Emails that have Errored Out with Updated Router or Authentication Information Resending Emails that have Errored Out with Updated Router or Authentication Information
Posted by March 1, 2019
BVSTools >> BVSTools Software Discussion >> Email Tools (MAILTOOL) Specific Discussion
BVSTools Offers Toolset to Work With HubSpot OAuth 2.0 APIs On Your IBM i BVSTools Offers Toolset to Work With HubSpot OAuth 2.0 APIs On Your IBM i
Posted by January 27, 2019
BVSTools >> BVSTools Announcements

Reply




Copyright 1983-2019 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).