Blog Archive

iSeries Save file (SAVF) - Save, Restore objects, library and IFS data

In iSeries(AS400) Save files are very handy in saving objects, complete libraries, IFS directories and files and then restoring them back on the same or different machine. You can even save a save file inside another save file.


Commands used to save Objects to save file

  • SAVOBJ
The Save Object (SAVOBJ) command saves a copy of a single object or a group of objects located in the same library. When saving to a save file, only one library can be specified. The types of objects that can be saved by this command are listed in the OBJTYPE parameter.

Examples:

Saving a few objects from a library to a save file
SAVOBJ OBJ(OBJECT1 OBJTECT2 OBJECT3 ...) LIB(OBJECT_LIBARRY_NAME) DEV(*SAVF) 
SAVF(SAVE_FILE_LIBRARY/SAVE_FILE_NAME) TGTRLS(*PRV)

Saving the complete library to a save file
SAVOBJ OBJ(*ALL) LIB(OBJECT_LIBRARY_NAME) DEV(*SAVF) 
SAVF(SAVE_FILE_LIBRARY/SAVE_FILE_NAME) TGTRLS(*PRV)

  • SAVLIB
The Save Library (SAVLIB) command allows you to save a copy of one or more libraries. When saving to a save file, only one library can be specified.

Example:
SAVLIB LIB(LIBRARY_NAME) DEV(*SAVF) SAVF(SAVE_FILE_LIBRARY/SAVE_FILE_NAME) 

  • SAV
The Save (SAV) command saves a copy of one or more objects that can be used in the integrated file system.

Examples:

Saving a few ifs objects to a save file
SAV DEV('/qsys.lib/') OBJ(
('/directory/file_name1.ext' *INCLUDE) 
('/directory/file_name2.ext' *INCLUDE))
TGTRLS(*PRV) 


Saving the complete directory to a save file
SAV DEV('/qsys.lib/save_file_library.lib/save_file_name.file') OBJ(
('/directory/*' *INCLUDE)) 
TGTRLS(*PRV) 



Commands used to restore Objects from save file

  • RSTOBJ
The Restore Object (RSTOBJ) command restores to the system a single object, or a group of objects, in a single library, that were saved in a save file by using a single command. The types of objects that can be restored by this command are listed in the OBJTYPE parameter.

Examples:

Restoring a few objects from a save file to a library
RSTOBJ OBJ(OBJECT1 OBJTECT2 OBJECT3 ...) SAVLIB(LIBRARY_OF_SAVED_OBJECTS) 
DEV(*SAVF) SAVF(SAVE_FILE_LIBRARY/SAVE_FILE_NAME) 
RSTLIB(RESTORE_TO_LIBRARY)    


Please note LIBRARY_OF_SAVED_OBJECTS and  RESTORE_TO_LIBRARY can be same ! 

Restoring all objects from a save file to a library
RSTOBJ OBJ(*ALL) SAVLIB(LIBRARY_OF_SAVED_OBJECTS) DEV(*SAVF) 
SAVF(SAVE_FILE_LIBRARY/SAVE_FILE_NAME) 
RSTLIB(RESTORE_TO_LIBRARY) 


  • RSTLIB
The Restore Library (RSTLIB) command restores to the system one library or a group of libraries that was saved by the Save Library (SAVLIB) command. The RSTLIB command restores the whole library, which includes the library description, object descriptions, and contents of the objects in the library

Example:
RSTLIB LIB(LIBRARY_NAME) DEV(*SAVF) SAVF(SAVE_FILE_LIBRARY/SAVE_FILE_NAME) 

  • RST
The Restore (RST) command restores a copy of one or more objects that can be used in the integrated file system.

Examples:

Restoring a few ifs objects from save file
RST DEV('/qsys.lib/save_file_library.lib/save_file_name.file') OBJ(
('/directory/file_name1.ext' *INCLUDE '/new_directory/file_name1.ext')
('/directory/file_name2.ext' *INCLUDE '/new_directory/file_name1.ext')) 
PATTERN((* *INCLUDE))

Restoring the complete directory from save file
RST DEV('/qsys.lib/save_file_library.lib/save_file_name.file') 
OBJ(('/directory/*' *INCLUDE '/new_directory/')) PATTERN((* *INCLUDE))