IBM i - Uploading your data to Azure
Thanks to Pixabay.com

IBM i - Uploading your data to Azure

I have written a previous post about using a small PASE script as a proof of concept on how to backup your IBM i on Azure. This is "not-so-small" script with menues to backup libraries on SAVF->Compress->Upload to Azure.

But I know there are people who love to feel the control from their CL command line. These are two simple CLs with NO error checking, NO fancy menu, NO encryption (but can be added with small changes) and NO warranty, but works and can be a first step to build your own script. For those who want to do these seriously we have a commercial product, but it's not part of this article.

#Pre-reqs

We need to install a couple of things to make the CLs work:

  • Use ACS or YUM and install nodejs. On this article I'm using V12
  • Install P7zip to compress data
  • With npm install "azure-storage-cmd" : npm install -g azure-storage-cmd
  • Create a symbolic link for the tool: ln -s /QOpenSys/pkgs/lib/nodejs12/bin/blob-cmd /usr/bin
  • If you don't have an Azure account yet, create one, the BLOB Container and get the key

1) Connect to your IBM i with SSH and run the following command

blob-cmd add-account <Account_Name> "<Key_Value>"

        

You can validate your configuration:


blob-cmd ls
        

2) Using "vi", "nano", "vim" or Notepad++ and the FTP extension create a small script. In my case: /home/DKESSELMAN/SCRIPTS/azput.sh


blob-cmd cp $1 $2
        

3) Create the CL for example #1 AZPUT


PGM? ? PARM(&FROMFILE &TOFILE)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? DCL? ? ? ? VAR(&AZPUTCMD) TYPE(*CHAR) LEN(512)? ? ? ? ? ? ? ? ? ? ?
? ? DCL? ? ? ? VAR(&FROMFILE) TYPE(*CHAR) LEN(128 )? ? ? ? ? ? ? ? ? ??
? ? DCL? ? ? ? VAR(&TOFILE) TYPE(*CHAR) LEN(128)? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? CHGVAR? ? ?VAR(&AZPUTCMD) VALUE('/QOpenSys/usr/bin/sh -c' +? ? ? ??
? ? ? ? ? ? ? ?*BCAT? '"/home/DKESSELMAN/SCRIPTS/azput.sh')? ? ? ? ? ??
? ? CHGVAR? ? ?VAR(&AZPUTCMD) VALUE(&AZPUTCMD *BCAT '''' *TCAT +? ? ? ?
? ? ? ? ? ? ?&FROMFILE *TCAT '''' *BCAT '''' *TCAT &TOFILE *TCAT '''' +
? ? ? ? ? ? ?*TCAT '"' )? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
?/* Debug */? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
?/* SNDMSG? ? ?MSG(&AZPUTCMD) TOUSR(*REQUESTER) */? ? ? ? ? ? ? ? ? ? ?
? ? QSH? ? ? ? CMD(&AZPUTCMD)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
ENDPGM? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?


        

This small CL just calls the script with the blob-cmd command and copy the local file to your Azure container on BLOB Storage facility.

4) This is example #2 AZPUTLIB

PGM? ? PARM(&LIBNAM &CNTNAME)? ? ? ? ? ? ? ? ? ? ? ? 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? DCL? ? ? ? VAR(&AZPUTCMD) TYPE(*CHAR) LEN(512)? ??
? ? DCL? ? ? ? VAR(&ZIPCMD)? ?TYPE(*CHAR) LEN(512)? ??
? ? DCL? ? ? ? VAR(&LIBNAM)? TYPE(*CHAR) LEN(10)? ? ??
? ? DCL? ? ? ? VAR(&CNTNAME)? TYPE(*CHAR) LEN(80)? ? ?
? ? DCL? ? ? ? VAR(&FROMFILE) TYPE(*CHAR) LEN(128)? ??
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? CRTLIB? ? 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? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? CHGVAR? ? ?VAR(&FROMFILE) VALUE('/home/backupsav/' +? ? ? ?
? ? ? ? ? ?*TCAT &LIBNAM *TCAT '.7z')? ? ? ? ? ? ? ? ? ? ??
? ? CHGVAR? ? ?VAR(&AZPUTCMD) VALUE('/QOpenSys/usr/bin/sh -c' +
? ? ? ? ? ?*BCAT? '"/home/DKESSELMAN/SCRIPTS/azput.sh')? ??
? ? CHGVAR? ? ?VAR(&AZPUTCMD) VALUE(&AZPUTCMD *BCAT? +? ? ? ? ?
? ? ? ? ? ?&FROMFILE *BCAT %TRIM(&CNTNAME) *TCAT '/' +? ? ?
? ? ? ? ? ?*TCAT &LIBNAM *TCAT '.7z"' )? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? ?SNDMSG? ? ?MSG(&AZPUTCMD) TOUSR(*REQUESTER)
? ? QSH? ? ? ? CMD(&AZPUTCMD)? ? ? ? ? ? ? ? ? ? ? ? ? ?
ENDPGM?        

This small CL saves data from one library on a SAVE FILE, then compress to the IFS and finally upload to Azure BLOB (&CNTNAME).

To get the right parameter for your container use the one listed with the command :

blob-cmd ls

Again, it's just a proof of concept, just works, but you can make yours, add encryption (don't worry, uploads are using SSL) or even create an image catalog and upload Virtual Tape or Virtual Optical images with your backups.

If you have any question just send me a message.

Good Luck!

Diego E. KESSELMAN

#ibmi #azure #powervs #cloud #powersystems #as400 #iseries #power #ibm #cloudbackup

Manu Gupta

Architect at EY GDS

1 年

Great article Diego. I wanted to understand how do we copy the files (json) in IFS to azure cloud?

回复
Oscar Mauricio Gaitan Duarte

Infrastructure | Cloud Computing | IBM Power Systems | Team Leadership | IT Project Management | IT Service Management | IT Risk Management

2 年

Great Diego, do you have it for AWS? I want to do something similar avoiding to use ICC

Pramod Koti

Principal Consultant - Enterprise Infrastructure Transformation at Infosys. Pre-sales, Solution and Consulting.

2 年

Thanks for sharing ..!!

要查看或添加评论,请登录

Diego E. KESSELMAN的更多文章

社区洞察

其他会员也浏览了