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 Now Allows Email Redirection for Development and Testing MAILTOOL Now Allows Email Redirection for Development and Testing
Posted by May 27, 2023
BVSTools >> BVSTools Announcements >> eMail Tool (MAILTOOL) Specific Announcements
GreenTools for Microsoft Apps (G4MS) Now Supports Footers When Sending Email GreenTools for Microsoft Apps (G4MS) Now Supports Footers When Sending Email
Posted by March 29, 2023
BVSTools >> BVSTools Announcements >> GreenTools for Microsoft Apps (G4MS) Specific Announcements
QuickBooks Online - Subtotals and Discounts Frustration QuickBooks Online - Subtotals and Discounts Frustration
Posted by March 16, 2023
QuickBooks >> QuickBooks Online
Making the Switch From QuickBooks Desktop to QuickBooks Online - No Picnic Making the Switch From QuickBooks Desktop to QuickBooks Online - No Picnic
Posted by March 16, 2023
QuickBooks >> QuickBooks Online
BVSTools Software Verified on V7R5 and Power10 BVSTools Software Verified on V7R5 and Power10
Posted by December 9, 2022
BVSTools >> BVSTools Announcements
Microsoft Office 365 Servers and Random Errors Issue Microsoft Office 365 Servers and Random Errors Issue
Posted by November 14, 2022
BVSTools >> BVSTools Software Discussion >> Email Tools (MAILTOOL) Specific Discussion
Sending/Resending Emails Using a MIME File with MAILTOOL Sending/Resending Emails Using a MIME File with MAILTOOL
Posted by November 8, 2022
BVSTools >> BVSTools Software Discussion >> Email Tools (MAILTOOL) Specific Discussion
Sending an HTML Email on Your IBM i Using MAILTOOL Sending an HTML Email on Your IBM i Using MAILTOOL
Posted by November 1, 2022
BVSTools >> BVSTools Software Discussion >> Email Tools (MAILTOOL) Specific Discussion
Transferring License Keys from One System to Another Transferring License Keys from One System to Another
Posted by October 31, 2022
BVSTools >> BVSTools Software Discussion
Calculating the Size of a File Before Base64 Encoding Calculating the Size of a File Before Base64 Encoding
Posted by August 13, 2022
Programming >> RPG Programming
GreenTools for Microsoft Apps (G4MS) v9.12 Now Includes Function to Send Emails using MIME File GreenTools for Microsoft Apps (G4MS) v9.12 Now Includes Function to Send Emails using MIME File
Posted by August 11, 2022
BVSTools >> BVSTools Announcements >> GreenTools for Microsoft Apps (G4MS) Specific Announcements
GreenTools for Google Apps (G4G) v15.20 Now Supports Shortcuts GreenTools for Google Apps (G4G) v15.20 Now Supports Shortcuts
Posted by August 6, 2022
BVSTools >> BVSTools Announcements >> GreenTools for G Suite (Google Apps) (G4G) Specific Announcements
GreenTools for Microsoft Apps (G4MS) Groups Admin Authority Instructions GreenTools for Microsoft Apps (G4MS) Groups Admin Authority Instructions
Posted by July 26, 2022
BVSTools >> BVSTools Software Discussion >> GreenTools for Microsoft Apps (G4MS) Specific Discussion
GreenTools for Microsoft Apps (G4MS) v9.10 Now Includes OneDrive Functions that Work With Groups/Shared Drives GreenTools for Microsoft Apps (G4MS) v9.10 Now Includes OneDrive Functions that Work With Groups/Shared Drives
Posted by July 19, 2022
BVSTools >> BVSTools Announcements >> GreenTools for Microsoft Apps (G4MS) Specific Announcements
GreenTools for Google Apps (G4G) v15.10 Now Includes Drive Functions that Work With Shared Drives GreenTools for Google Apps (G4G) v15.10 Now Includes Drive Functions that Work With Shared Drives
Posted by July 15, 2022
BVSTools >> BVSTools Announcements >> GreenTools for G Suite (Google Apps) (G4G) 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).