IBM i - Uploading your data to Azure
Diego E. KESSELMAN
Helping Businesses Move IBM Power Workloads to the Cloud | IBM i/AIX/Linux Expert | IBM Champion 2022-2025 | "IBM i en Espa?ol" & "IBM_PowerVS_en_Espa?ol" (Telegram) Admin
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:
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? ? ?BACKUPSAV? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? MONMSG? ? ?MSGID(CPF0000)? ? ? ? ? ? ? ? ? ? ? ? ?
? ? CRTSAVF? ? BACKUPSAV/&LIBNAM? ? ? ? ? ? ? ? ? ? ??
? ? MONMSG? ? ?MSGID(CPF0000)? ? ? ? ? ? ? ? ? ? ? ? ?
? ? CLRSAVF? ? BACKUPSAV/&LIBNAM? ? ? ? ? ? ? ? ? ? ??
? ? SAVLIB? ? ?LIB(&LIBNAM) DEV(*SAVF) +? ? ? ? ? ? ??
? ? ? ? ? ? ? ?SAVF(BACKUPSAV/&LIBNAM) SAVACT(*LIB) +?
? ? ? ? ? ? ? ?SAVACTWAIT(60)? ? ? ? ? ? ? ? ? ? ? ? ?
? ? CHGVAR? ? ?VAR(&FROMFILE) VALUE('/QSYS.LIB/BACKUPSAV.LIB/' +? ? ??
? ? ? ? ? ?*TCAT &LIBNAM *TCAT '.FILE')? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? CHGVAR? ? ?VAR(&ZIPCMD) VALUE('/QSYS.LIB/BACKUPSAV.LIB/' +? ? ? ??
? ? ? ? ? ?*TCAT &LIBNAM *TCAT '.FILE')? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? CHGVAR? ? ?VAR(&zipCMD) VALUE('/QOpenSys/usr/bin/sh -c " +? ? ? ??
? ? ? ? ? ?/QOpenSys/pkgs/bin/7za a' *BCAT '/home/backupsav/' +? ?
? ? ? ? ? ?*TCAT &LIBNAM *TCAT '.7z? /QSYS.LIB/BACKUPSAV.LIB/' +??
? ? ? ? ? ?*TCAT &LIBNAM *TCAT '.FILE' *TCAT '"')? ? ? ? ? ? ? ? ?
? ? QSH? ? ? ? CMD(&ZIPCMD)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? 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
Architect at EY GDS
1 年Great article Diego. I wanted to understand how do we copy the files (json) in IFS to azure cloud?
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
Principal Consultant - Enterprise Infrastructure Transformation at Infosys. Pre-sales, Solution and Consulting.
2 年Thanks for sharing ..!!