Admin Alert: Five Minutes to Moving System i Objects Between Partitions
Published: February 27, 2008
by Joe Hertvik
Administrators in multiple System i environments are frequently called upon to save and restore files from one i5/OS machine to another. Because you may not always remember the exact steps involved in performing a transfer, this week I'm presenting a five-minute cheat sheet that details every step you need to perform in order to easily save an object and move it to a companion machine via FTP.
The Basic Game Plan
When moving objects between System i partitions, there are five critical steps that you need to follow.
- Creating or clearing an i5/OS save file on the source system
- Saving the object(s) to the save file
- Prepping the save file on the target system
- FTPing the save file between the source and target system
- Restoring the object to the target system
Get your stopwatches ready, because here's how to do all five steps in five minutes or less.
The File In Question
To illustrate this process, I'll be transferring the Client Access sample customer file (QCUSTCDT) between a source and a target System i partition. QCUSTCDT is a standard file that IBM has provided with most versions of the i5/OS and the older OS/400 operating systems. It can usually be found in the QIWS library on your system. For this example, I'll be saving and transferring the file from my source System i partition to a library named HOLD on my target machine.
Step 1: Create or Clear an i5/OS Save File
i5/OS save files are normally used to transfer reasonably sized objects between systems. Save files can be quickly created, and they are used to save any type of system object that could normally be saved to media.
For our example, we'll use a save file called GARBAGE that resides in the HOLD library on the source system. Before you start the save, you need to ensure that the save file is created on the system and that it is empty. If you don't currently have a GARBAGE file on your system, you can use the following Create Save File (CRTSAVF) command to create one.
CRTSAVF FILE(HOLD/GARBAGE) TEXT('Save file for transferring data')
This command creates a new empty file for transferring your data. If you already have a GARBAGE save file and you want to clear it before saving the data, use the following Clear Save File (CLRSAVF) command.
Step one is complete. Now you're ready to save your QCUSTCDT object.
Step 2: Save the Object To the Save File
Saving the object is an extremely simple process. To save our QCUSTCDT object from QIWS into the GARBAGE save file, you can execute the following SAVOBJ command on the source system.
SAVOBJ OBJ(QCUSTCDT) LIB(QIWS) DEV(*SAVF) SAVF(HOLD/GARBAGE)
This SAVOBJ command is the same command that you would use if you were saving QCUSTCDT to media. The only difference is that instead of entering a media drive name into the device (DEVICE) parameter, I entered the '*SAVF' literal, which denotes that this object will be saved to an i5/OS save file. To denote the save file name and library, you enter that location in the save file (SAVF) parameter. Using this command, the file is quickly saved to the HOLD/GARBAGE save file.
Step 3: Prepping the Save File on the Target System
Before you can transfer the save file containing the QCUSTCDT object, you need to ensure that one of the following situations exist on your target partition.
- If the save file already exists in the library you'll be transferring to, the file needs to be cleared so that it can accept the data that will be transferred from the source machine. If the file is not cleared, the FTP transfer will not work properly. Or…
- The save file does not exist on the target partition
If you're transferring the GARBAGE save file to the HOLD library on the target partition and that library already has a GARBAGE save file, you can use the same CLRSAVF command that I described in step two to clear the target partition save file.
If the GARBAGE file doesn't already exist on the target system, don't worry. The FTP file transfer sub-commands that I'll explain in step four will automatically create the GARBAGE file on your target partition, if the file isn't there.
Now you're ready to transfer.
Step 4: FTP the Save File Between the Source and Target System
After the prep work is complete, you can move the GARBAGE save file containing your data to the target system by using an FTP file transfer. To do that, you must start the FTP server on both systems, if it's not already started. Run the following Start TCP/IP Server (STRTCPSVR) command on both systems to start your FTP servers.
Once FTP is started, open an FTP session on the source box by running this Start TCP/IP File Transfer (FTP) command.
FTP RMTSYS(Target_system_name or IP_address)
Since you will be transferring the save file from the source partition, that partition is functioning as the FTP client and the target partition is functioning as the FTP server. After the FTP session starts, it will ask you to log on to the FTP server by providing a valid FTP server user ID and password. Once you're signed on, you can execute the following FTP sub-commands to transfer the GARBAGE save file from your source to your target system.
quote site namefmt 0
quote site namefmt 1
These commands perform the following functions.
- quote site namefmt 0--This line allows you to run the FTP Select File Naming Format sub-command on both systems. The NAMEFMT sub-command changes the file naming format convention used in this FTP session. When specifying NAMEFMT 0, all location and file references can only be specified with native i5/OS library and object names. Using NAMEFMT 0 makes it easier to change the remote and local working directory names in the next two FTP sub-commands.
- cd hold--This Change Working Directory or Library sub-command changes the default working directory on the FTP client (the source partition, in this case) to point to the HOLD library where your GARBAGE save file is located. If the working directory is not explicitly specified in other FTP sub-commands, client FTP transfers will search for the file to be transferred in the HOLD library.
- lcd hold--This variation on the Change Working Directory or Library sub-command changes the default working directory on the FTP server (the target partition) to the HOLD library. This designates that any transferred files will be deposited in HOLD.
- bin--Designates that the FTP file transfer will be a binary image transfer. In a binary transfer, files are transmitted in a continuous data stream without any transformation between the source and the target machine. Save file transfers are required to use binary image transfer.
- quote site namefmt 1--Reverses the first NAMEFMT sub-command, and changes the file naming format convention for this session to use the AS/400 Integrated File System (AS/400 IFS) naming convention. The IFS naming convention is required for the actual transfer in order to designate that you are transferring an i5/OS save file instead of a data file.
- put garbage.savf--Transfers the GARBAGE save file from the working directory on the FTP client (the HOLD library) to the working directory on the FTP server (also the HOLD library). The .savf extension tells FTP that this is a save file and it provides for the effective transfer of the save file contents. The file will not transfer correctly if you don't add the .savf literal to the end of the file name to be transferred. If the save file does not exist on the target machine, FTP will create a new save file as the transfer is happening.
- quit--Exits the FTP session.
After executing these FTP sub-commands, a copy of the GARBAGE save file containing the QCUSTCDT file will now reside in the HOLD library on the target machine.
Step 5: Restoring the Object To the Target System
Once the save file is transferred, it's relatively easy to restore the file to the HOLD library on the target system. In this case, you would use the following Restore Object (RSTOBJ) command to restore the object from the GARBAGE save file.
RSTOBJ OBJ(QCUSTCDT) SAVLIB(QIWS) DEV(*SAVF) SAVF(HOLD/GARBAGE)
MBROPT(*ALL) ALWOBJDIF(*ALL) RSTLIB(HOLD)
If a copy of QCUSTCDT already exists in the library, this particular command will use the Allow Object Differences (ALLOBJDIF) parameter and the Data Base Member Option (MBROPT) parameter to overwrite the existing file.
I'm Afraid Our Time Is Up
And that's how you can use FTP to easily transfer a file from one i5/OS partition to another partition in five minutes or less. To adapt this template to your situation, you would simply change your SAVOBJ and RSTOBJ commands to specify other objects. If you wanted to transfer different types of objects, such as AS/400 IFS files, DLO files, programs, or source code file, you can continue to use the procedure as listed here. The only difference is that you should execute the proper i5/OS SAVxxx and RSTxxx commands to save and restore the objects from your GARBAGE save file.
About Our Testing Environment
Configurations described in this article were tested on an i5 550 box running i5/OS V5R3. Most of the commands shown here are also available in earlier and later versions of the operating system running on iSeries or AS/400 machines. If a command or function is present in earlier versions of the i5/OS or OS/400 operating systems, you may notice some variations in the pre-V5R3 copies of these commands. These differences may be due to command improvements that have occurred from release to release.
Post this story to del.icio.us
Post this story to Digg
Post this story to Slashdot