Command reference / save

SAV

Save Object

The Save (SAV) command saves a copy of one or more objects that can be used in the integrated file system. For more information about integrated file system commands, see the Integrated file system topic collection in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/.

Allowed environments: *ALL. Positional parameters: 2.

Restrictions

Parameters

DEV Dev

Specifies the device to which the objects are to be saved. For more information on specifying device path names, refer to "Specifying the device name" in the Backup and recovery topic collection in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/. This is a required parameter. Note: This parameter is Unicode-enabled. See "Unicode support in CL" in the CL topic collection in the Programming category in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/ for additional information.

Type
*PNAME
Required
Yes
Length
5000
List limit
4
Case
Mixed case
'save-file-path-name'
Specify the path name of the save file used to save the objects.
'optical-device-path-name'
Specify the path name of the optical device used to save the objects.
'tape-media-library-device-path-name'
Specify the path name of the tape media library device used to save the objects.
'tape-device-path-name'
Specify the path name of the tape device used to save the objects. A maximum of four tape devices can be specified. If a virtual tape device is used, it must be the only device specified.
'media-definition-path-name'
Specify the path name of the media definition (*MEDDFN) object that identifies the devices and media used to contain the saved data. For information about creating a media definition, see the Create Media Definition API in the APIs topic collection in the Programming category in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/. For information about using a media definition, see the Recovering your system book, SC41-5304 and the Back up your server topic in the Backup and recovery topic collection in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/.

OBJ Objects

Specifies the objects to be saved. You can specify an object name pattern for the path name to be used. When a path name is specified that could match many objects, you can specify a value for the Name pattern (PATTERN) parameter to subset the objects that are to be saved. A maximum of 300 path names can be specified. For more information on specifying path names, refer to "Object naming rules" in the CL topic collection in the Programming category in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/. Additional information about object name patterns is in the Integrated file system topic collection in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/. Note: This parameter is Unicode-enabled. See "Unicode support in CL" in the CL topic collection in the Programming category in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/ for additional information. Specifies whether names that match the pattern should be included or omitted from the operation. Note that in determining whether a name matches a pattern, relative name patterns are always treated as relative to the current working directory. Note: The SUBTREE parameter determines whether the subtrees are included or omitted.

Type
*ELEM
Required
No
Default
(*)
List limit
300
Case
Uppercase
'*'
The objects in the current directory are saved.
path-name
Specify an object path name or a pattern that can match many names.
*INCLUDE
The objects that match the object name pattern are to be saved, unless overridden by an *OMIT specification.
*OMIT
The objects that match the object name pattern are not saved. This overrides an *INCLUDE specification and is intended to be used to omit a subset of a previously selected pattern.
Elements in order

Element Element

Type
*PNAME
Required
Yes
Length
5000
Case
Mixed case

Element Element

Type
*CHAR
Required
No
Default
*INCLUDE
Length
8
Case
Uppercase

Allowed values: *INCLUDE, *OMIT

SUBTREE Subtree

Specifies whether directory subtrees are included in the save operation.

Type
*CHAR
Required
No
Default
*ALL
Length
5
Case
Uppercase

Allowed values: *ALL, *DIR, *NONE, *OBJ, *STG

*ALL
The entire subtree of each directory that matches the object name pattern is included. The subtree includes all subdirectories and the objects within those subdirectories.
*DIR
The objects in the first level of each directory that matches the object name pattern are included. The subdirectories of each matching directory are included, but the objects in the subdirectories are not included.
*NONE
No subtrees are included in the save operation. If a directory matches the object name pattern specified, the objects in the directory are included. If the directory has subdirectories, neither the subdirectories nor the objects in the subdirectories are included.
*OBJ
Only the objects that exactly match the object name pattern will be processed. If the object name pattern specifies a directory, objects in the directory are not included.
*STG
The objects that match the object name pattern are processed along with the storage for related objects. Objects that are saved using this value can only be restored using SUBTREE(*STG).

VOL Vol

Specifies the volume identifiers of the volumes, or the cartridge identifiers of tapes in a tape media library device, on which the data is saved. The volumes must be placed in the device in the same order as specified for this parameter. A maximum of 75 volume identifiers can be specified. After all specified volumes are filled, the save operation continues on whatever volumes are placed in the device.

Type
*CHAR
Required
No
Default
*MOUNTED
Length
6
List limit
75
Case
Uppercase

Suggested / special values: *MOUNTED

*MOUNTED
The data is saved on the volumes placed in the device. For a media library device, the volume to be used is the next cartridge in the category mounted by the Set Tape Category (SETTAPCGY) command. Note: This value cannot be specified when using an optical media library device.
character-value
Specify the identifiers of one or more volumes in the order in which they are placed in a device and used to save the data.

LABEL Label

Specifies the file identifier of the media to be used for the save operation.

Type
*CHAR
Required
No
Default
*GEN
Length
17
Case
Uppercase

Suggested / special values: *GEN

*GEN
The file label is created by the system. For objects in libraries, this is the equivalent of LABEL(*LIB) on the Save Object (SAVOBJ) and Save Library (SAVLIB) commands. For document library objects, this is the equivalent of LABEL(*GEN) on the Save Document Library Object (SAVDLO) command. For objects in other file systems, the label is SAVyyyymmdd.
character-value
Specify the identifier (up to 17 characters) of the tape file used for the save operation.

SEQNBR Seqnbr

Specifies, when tape is used, the sequence number to use as the starting point for the save operation.

Type
*UINT4
Required
No
Default
*END
Range
1 to 16777215
Case
Uppercase

Suggested / special values: *END

*END
The save operation begins after the last sequence number on the first tape. If the first tape is full, an error message is issued and the operation ends.
1-16777215
Specify the sequence number of the file to be used for the save operation.

ENDOPT Endopt

Specifies the operation that is automatically done on the tape or optical volume after the save operation ends. If more than one volume is used, this parameter applies only to the last volume used; all other volumes are unloaded when the end of the volume is reached. Note: This parameter is valid only if a tape or optical device name is specified for the DEV parameter. For optical devices, *UNLOAD is the only special value supported, *REWIND and *LEAVE will be ignored.

Type
*CHAR
Required
No
Default
*REWIND
Length
7
Case
Uppercase

Allowed values: *REWIND, *LEAVE, *UNLOAD

*REWIND
The tape is automatically rewound, but not unloaded, after the operation has ended.
*LEAVE
The tape does not rewind or unload after the operation ends. It remains at the current position on the tape drive.
*UNLOAD
The tape is automatically rewound and unloaded after the operation ends. Some optical devices will eject the volume after the operation ends.

EXPDATE Expdate

Specifies the expiration date of the file created by the save operation. If a date is specified, the file is protected and cannot be overwritten until the specified expiration date. This parameter is valid for tape and optical files. Specifying this parameter does not protect against a later save operation specifying CLEAR(*ALL).

Type
*DATE
Required
No
Default
*PERM
Case
Uppercase

Suggested / special values: *PERM

*PERM
The file is protected permanently.
date
Specify the date when protection for the file ends.

CLEAR Clear

Specifies whether active data on the media is automatically cleared or replaced. Active data is any file on the media that has not expired. For saves to tape, clearing active data will make any files on the tape volume beyond the last file written by the save operation no longer accessible. For saves to optical, the files written by the save operation can be automatically replaced while other files on the volume remain active, or all active files can be automatically cleared. Clearing does not erase the data, it just makes the files no longer accessible. Clearing a tape does not initialize it. You should initialize tapes to a standard label format before the save command is issued by using the Initialize Tape (INZTAP) command and specifying a value for the NEWVOL parameter. Clearing an optical volume does initialize it. If a volume that is not initialized is encountered during the save operation, an inquiry message is sent and an operator can initialize the volume. If tapes are used and a sequence number is specified for the SEQNBR parameter, the first tape is cleared beginning at that sequence number. All tapes following that first tape are completely cleared. To clear the entire first tape, SEQNBR(1) must be specified.

Type
*CHAR
Required
No
Default
*NONE
Length
8
Case
Uppercase

Allowed values: *NONE, *ALL, *AFTER, *REPLACE

*NONE
None of the media is automatically cleared. If the save operation encounters active data on a tape volume or in a save file, an inquiry message is sent, allowing the operator to either end the save operation or clear the media. If the save operation encounters the specified optical file, an inquiry message is sent, allowing the operator to either end the save operation or replace the file.
*ALL
All of the media is automatically cleared.
*AFTER
All media after the first volume is automatically cleared. If the save operation encounters active data on the first tape volume, an inquiry message is sent, allowing the operator to either end the save operation or clear the media. If the save operation encounters the specified optical file on the first volume, an inquiry message is sent, allowing the operator to either end the save operation or replace the file.
*REPLACE
Active data on the media is automatically replaced. Optical volumes are not initialized. Other media is automatically cleared in the same way as the *ALL value.

TGTRLS Tgtrls

Specifies the release level of the operating system on which you intend to use the object being saved. When specifying the target-release value, the format VxRxMx is used to specify the release, where Vx is the version, Rx is the release, and Mx is the modification level. For example, V5R3M0 is version 5, release 3, modification 0. Valid values depend on the current version, release, and modification level of the operating system, and they change with each new release. You can press F4 while prompting this command parameter to see a list of valid target release values.

Type
*CHAR
Required
No
Default
*CURRENT
Length
8
Case
Uppercase

Allowed values: *CURRENT, *PRV, V7R3M0, V7R4M0, V7R5M0

*CURRENT
The object is to be restored to, and used on, the release of the operating system currently running on your system. The object can also be restored to a system with any subsequent release of the operating system installed.
*PRV
The object is to be restored to the previous release with modification level 0 of the operating system. The object can also be restored to a system with any subsequent release of the operating system installed.
character-value
Specify the release in the format VxRxMx. The object can be restored to a system with the specified release or with any subsequent release of the operating system installed.

PVTAUT Private authorities

Specifies whether to save private authorities with the objects that are saved. Saving private authorities will increase the amount of time it takes to save the objects, but it can simplify the recovery of an object or a group of objects. It will not simplify the recovery of an entire system.

Type
*CHAR
Required
No
Default
*NO
Length
4
Case
Uppercase

Allowed values: *NO, *YES

*NO
No private authorities are saved.
*YES
Private authorities are saved for each object that is saved. Note: You must have save system (*SAVSYS) or all object (*ALLOBJ) special authority to specify this value.

Examples

SAV DEV('/QSYS.LIB/TAP01.DEVD') OBJ(('/*') ('/QSYS.LIB' *OMIT) ('/QDLS' *OMIT))

Saving All Data Not in Libraries and Not Document Library Objects. This command saves all objects that are not in libraries and are not document library objects.

SAV DEV('/QSYS.LIB/TAP01.DEVD') OBJ(('/*') ('/QSYS.LIB' *OMIT) ('/QDLS' *OMIT)) CHGPERIOD(*LASTSAVE)

Saving Changes Since the Last Time the Objects Were Saved. This command saves all objects that are not in libraries, that are not document library objects, and that have changed since the last time they were saved with UPDHST(*YES) specified.

SAV DEV('/QSYS.LIB/TAP01.DEVD') OBJ(('/*') ('/QSYS.LIB' *OMIT) ('/QDLS' *OMIT)) CHGPERIOD((*ALL *ALL '12/31/99'))

Saving Data That Has Not Changed Since 1999. This command saves all objects that are not in libraries, that are not document library objects, and that have not changed since December 31, 1999.

SAV DEV('/QSYS.LIB/TAP01.DEVD')

Saving All Objects in the Current Directory. This command uses the default value '*' on the OBJ parameter to save all objects in the current directory and its subdirectories. This example is not valid if the current directory is the root directory or if the current directory is in the QDLS file system.

SAV DEV('/QSYS.LIB/TAP01.DEVD') OBJ('*') SUBTREE(*NONE)

This command saves all objects in the current directory but not in the subdirectories.

SAV DEV('/QSYS.LIB/TAP01.DEVD') OBJ(('*') ('**.BACKUP' *OMIT) ('**.TEMP' *OMIT))

Omitting Objects During a Save Operation. This command saves all objects in the current directory except those with extensions of .BACKUP and .TEMP (the entire subtrees of directories with these extensions are omitted).

SAV DEV('/QSYS.LIB/TAP01.DEVD') OBJ(('/A') ('/A/B/C' *OMIT))

This command saves all objects in directory /A and its subdirectories, except those in directory /A/B/C.

SAV DEV('/QSYS.LIB/TAP01.DEVD') OBJ('/QSYS.LIB/A.LIB')

Saving a Library. This command saves library A on the tape device named TAP01.

SAV DEV('/QSYS.LIB/TAP01.DEVD') OBJ('/QSYS.LIB/A.LIB')
SAV DEV('/QSYS.LIB/TAP01.DEVD') OBJ('/QSYS.LIB/B.LIB')

Saving Two Libraries. These two commands save two libraries. The first command saves library A and the second command saves library B.

SAV DEV('/QSYS.LIB/TAP01.DEVD') OBJ('/QSYS.LIB/MYLIB.LIB/*.FILE')

Saving All Files in a Library. This command saves all files in the library MYLIB on the tape device named TAP01.

SAV DEV('/QSYS.LIB/TAP01.DEVD') OBJ('/QSYS.LIB/MYLIB.LIB/MYPGM.PGM')
SAV DEV('/QSYS.LIB/TAP01.DEVD') OBJ('/QSYS.LIB/MYLIB.LIB/MYFILE.FILE')

Saving Two Objects in a Library. These two commands save two objects in the same library. This first command saves the program MYPGM from library MYLIB. The second command saves the file MYFILE from library MYLIB.

SAV DEV('/QSYS.LIB/TAP01.DEVD') OBJ('/MyDir/MyFile')
SAV DEV('/QSYS.LIB/TAP01.DEVD') OBJ('/QSYS.LIB/MYLIB.LIB/MYFILE.FILE')
SAV DEV('/QSYS.LIB/TAP01.DEVD') OBJ('/QDLS/MYFLR/MYDOC') SUBTREE(*OBJ) UPDHST(*YES)

Saving a Stream File, a Database File, and a Document. Three commands are used in this example to save three objects. The first command saves the stream file MyFile in the directory MyDir on the tape device named TAP01. The second command saves the database file MYFILE in the library named MYLIB on the tape device named TAP01. The third command saves the document MYDOC in a folder named MYFLR on the tape device named TAP01.

SAV DEV('/QSYS.LIB/MYLIB.LIB/MYSAVF.FILE') OBJ(MYDIR)

Saving to a Save File. This command saves the directory MYDIR to a save file named MYSAVF.

SAV DEV('DevLink') OBJ(('DirLink') ('FileLink') ('DirLink/*')) SAVACT(*YES) SAVACTMSGQ('MsgqLink')

Using Symbolic Links for the Save Operation. This command assumes that the current directory contains the following symbolic links: In the IBM example, DevLink points to /QSYS.LIB/TAP01.DEVD, DirLink to /SomeDirectory, FileLink to /SomeDirectory/SomeFile, and MsgqLink to /QSYS.LIB/LIB1.LIB/MSGQ1.MSGQ.

SAV DEV('/QSYS.LIB/MYLIB.LIB/MYSAVF.FILE') OBJ(('/QFPNWSSTG/MYDISK')) SAVACT(*YES) SAVACTOPT(*NWSSTG)

Saving a Storage Space While it is Active. This command saves the objects associated with storage space '/QFPNWSSTG/MYDISK' even if the associated *NWSD is varied on.

SAV DEV('/QSYS.LIB/MYLIB.LIB/MYSAVF.FILE') OBJ(('/QNTC/MYSERVER/MYSHARE'))

Saving Shares from a Windows, Linux or AIX Server. This command saves share MYSHARE and all of the objects the share contains from a server named '/QNTC/MYSERVER'. The example assumes that server MYSERVER was properly configured prior to running the SAV command. For more information on file level backup for Windows, Linux and AIX servers, see the Backup and recovery topic collection in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/.

IBM command documentation

Generated from os/cl/catalog/SAV.json and os/cl/help/SAV.json.