What is the difference between Save Commands (SAVOBJ, SAVLIB, SAVSYS)?

ou're asking about the core save commands on IBM i (formerly AS400), used for backing up your system and data. Here's a breakdown of SAVOBJ, SAVLIB, and SAVSYS:

SAVOBJ (Save Object)

  • Granular Control: SAVOBJ allows you to save individual objects or specific groups of objects within a library. This gives you very fine-grained control over what you're backing up.
  • Use Cases:
    • Saving specific programs or files that have been modified.
    • Backing up critical objects without saving an entire library.
    • Archiving individual objects.
  • Example:
    SAVOBJ OBJ(MYPROG) LIB(MYLIB) SAVF(MYLIB/SAVEFILE1)
    
    This command saves the program MYPROG from library MYLIB to the save file SAVEFILE1 in MYLIB.

SAVLIB (Save Library)

  • Library-Level Backup: SAVLIB is used to save an entire library, including all the objects within it (programs, files, data areas, etc.).
  • Use Cases:
    • Regularly backing up libraries to protect against data loss.
    • Creating copies of libraries for testing or development.
    • Moving libraries to another system.
  • Example:
    SAVLIB LIB(MYLIB) SAVF(MYLIB/SAVEFILE2)
    
    This command saves the entire library MYLIB to the save file SAVEFILE2 in MYLIB.

SAVSYS (Save System)

  • Full System Backup: SAVSYS is the most comprehensive save command. It backs up the entire system, including the operating system, licensed programs, user profiles, configuration objects, and all user data.
  • Use Cases:
    • Disaster recovery: Creating a complete backup of the system in case of a major failure.
    • System upgrades: Backing up the system before applying updates or installing new software.
    • System migration: Moving the entire system to another machine.
  • Important Notes:
    • SAVSYS must be run in a restricted state, meaning that most users and applications need to be offline.
    • It's typically performed during off-peak hours or scheduled downtime.
    • It's crucial for a complete and restorable backup of your IBM i environment.
  • Example:
    SAVSYS DEV(TAP01)
    
    This command saves the entire system to the tape device TAP01.

Key Differences Summarized:

Feature SAVOBJ SAVLIB SAVSYS
Scope Individual objects or groups of objects Entire library Entire system
Granularity Very fine-grained Library level System level
Use Cases Specific object backups, archiving Library backups, copies, migrations Disaster recovery, system upgrades, migrations
State Can be run online (for most objects) Can be run online (for most libraries) Must be run in a restricted state