Implementation Details
Creating Virtual Tape System
We recommend that you read the following RedBook on Virtual Tape system http://www.redbooks.ibm.com/abstracts/sg247164.html
In this section, we will present commands to create a Virtual Tape
DEV1
and a Catalog CAT1
.
The first step is to create the Virtual Tape device and set the various parameters.
CRTDEVTAP DEVD(DEV1) RSRCNAME(*VRT) ONLINE(*YES)
VRYCFG CFGOBJ(DEV1) CFGTYPE(*DEV) STATUS(*ON)
Then through FTP, you can create the Catalog CAT1
that will store
volumes into /CAT1
directory. It is important to exclude the
/CAT1
directory from backup.
CRTIMGCLG IMGCLG(CAT1) DIR('/CAT1') CRTDIR(*YES) TYPE(*TAP)
CHGATR OBJ('/CAT1') ATR(*ALWSAV) VALUE(*NO)
Once done, you can create volumes in the catalog, the initial size will
be minimal, and you can set the maximum size IMGSIZ
to something
coresponding to your real tape device in order to allow copy from
Virtual Tapes to Real Tapes. However, note that it will be more
convenient if your daily backups fit on a single volume.
ADDIMGCLGE IMGCLG(CAT1) FROMFILE(*NEW) TOFILE(VOL001) IMGSIZ(10000)
ALCSTG(*MIN) VOLNAM(VOL001) VOLTYP(*SL) DENSITY(*VRT256K)
ADDIMGCLGE IMGCLG(CAT1) FROMFILE(*NEW) TOFILE(VOL002) IMGSIZ(10000)
ALCSTG(*MIN) VOLNAM(VOL002) VOLTYP(*SL) DENSITY(*VRT256K)
ADDIMGCLGE IMGCLG(CAT1) FROMFILE(*NEW) TOFILE(VOL003) IMGSIZ(10000)
ALCSTG(*MIN) VOLNAM(VOL003) VOLTYP(*SL) DENSITY(*VRT256K)
Running a Backup
Now you are ready to run your first backup.
SAVLIB QUSRSYS DEV(DEV1) VOL(VOL001) OUTPUT(*PRINT) INFTYPE(*ERR)
Getting Logs
To retrieve the backup output using FTP, you can store logs to a library
LOGS
CRTLIB LIB(LOGS)
To transfer the backup log from the Printer to the LOGS
library, you
can use the following command:
DLTF LOGS/BACKUP
CRTPF FILE(LOGS/BACKUP) RCDLEN(133)
CPYSPLF FILE(QPSAVOBJ) JOB(*) MBROPT(*ADD) SPLNBR(*LAST) TOFILE(LOGS/BACKUP)
To clear a volume (after a successful FTP transfer), use the following command:
INZTAP CHECK(*NO) DEV(DEV1) NEWVOL(VOL001) VOL(VOL001) CLEAR(*YES)
Running Script Remotely
To run a script remotely, use the RCMD FTP command as in the following example, the script will create a backup of the library YOURLIB in a SAVF file, and retrieve it.
cat << EOF > ftp.txt
user YOURPROFILE YOURPASSWORD
bin
quote rcmd CRTSAVF QTEMP/YOURLIB
quote rcmd SAVLIB YOURLIB dev(*savf) SAVF(QTEMP/YOURLIB) DTACPR(*YES) OUTPUT(*PRINT)
get QTEMP/YOURLIB YOURLIB.savf
quote DLTF QTEMP/YOURLIB
quit
EOF
ftp -n -i -s:ftp.txt as400host
Remote Backup
The following script is an example to backup two libraries (YOURLIB
,
OTHERLIB
), retrieve the volume and backup status.
#!/bin/bash
mkdir -p /opt/bacula/working/as400
cd /opt/bacula/working/as400
rm -f VOL001 BACKUP-001.log
cat << EOF > ftp.txt
user YOURPROFILE YOURPASSWORD
quote rcmd CRTPF FILE(LOGS/BACKUP) RCDLEN(133)
quote rcmd SAVLIB YOURLIB DEV(DEV1) VOL(VOL001) DTACPR(*YES) OUTPUT(*PRINT)
quote rcmd CPYSPLF FILE(QPSAVOBJ) JOB(YOURPROFILE/QPRTJOB) MBROPT(*ADD) SPLNBR(*LAST) TOFILE(LOGS/BACKUP)
quote rcmd SAVLIB OTHERLIB DEV(DEV1) VOL(VOL001) DTACPR(*YES) OUTPUT(*PRINT)
quote rcmd CPYSPLF FILE(QPSAVOBJ) JOB(YOURPROFILE/QPRTJOB) MBROPT(*ADD) SPLNBR(*LAST) TOFILE(LOGS/BACKUP)
ascii
get LOGS/BACKUP BACKUP-001.log
quote rcmd DLTF LOGS/BACKUP
quit
EOF
cat << EOF > ftp-get-volume.txt
user YOURPROFILE YOURPASSWORD
bin
cd /CAT1
get VOL001
quit
EOF
ftp as400host < ftp.txt
cat BACKUP-001.log
ftp as400host < ftp-get-volume.txt
Integration with Bacula
You can use the RunBeforeJob command to execute the backup and retrieve the result. Note that you can schedule the backup on your AS/400 server, and just get the result in the FTP script.
Job {
Name = AS400_QUSRSYS
Client = director-fd
RunBeforeJob = "/opt/bacula/scripts/backup_as400.sh"
RunBeforeJob = "cat /opt/bacula/working/as400/BACKUP-001.log"
FileSet = FS_AS400
...
}
FileSet {
Name = FS_AS400
Include {
File = /opt/bacula/working/as400
}
}
The cat
command will display the AS/400 backup log in the Bacula
script as in this example.
5722SS1 V5R4M0 060210 Save Library - Object Information
Device . . . . . . . . : DEV1
Target release . . . . : V5R4M0 Storage . . . . . . . : *KEEP
Save access paths . . : Yes Save file data . . . . : Yes
Data compressed . . . : No Data compacted . . . . : No
Expiration date . . . : *PERM
Library . . . . . . . : TEST
Save date/time . . . . : 09/24/22 10:12:18
Object Type Attribute Saved Size Owner Text
TEST *LIB PROD YES 86016 QSECOFR
Library ------Objects------ File File
Library ASP Saved Saved Not saved Volume Label Sequence Owner Size Text
TEST 1 YES 1 0 VOL001 TEST 8 QSECOFR 86016
* * * * * E N D O F L I S T I N G * * * * *
See also
Go back to:
Go back to the AS/400 Backup chapter.
Go back to the main Advanced Features Usage page.