Previous Page | Next Page

Using the %OMABAKUP Macro to Perform Backups and Restores

Writing Custom Programs Using %OMABAKUP


Writing a Custom Program to Perform a Full Metadata Server Backup

Use the following steps to create a custom program that performs a full metadata server backup:

  1. Create and secure a directory in the path where the backup files will be stored. You can use the following directory, which is provided in your deployment:

    • On Windows: SAS-configuration-directory\Lev1\SASMeta\MetadataServer\SASBackup

    • On UNIX and z/OS: SAS-configuration-directory/Lev1/SASMeta/MetadataServer/SASBackup

    The full pathname of a backup repository cannot exceed 200 characters.

    Use operating system permissions to secure the directory. The permissions should deny access to anyone other than the user who will run the backup or restore programs.

  2. Create a SAS program with server connection parameters and the %OMABAKUP macro, as follows:

    1. Use the following syntax to include the file that contains server connection parameters:

      FILENAME METAPARM "path-to-metaparms.sas-file";
      %INCLUDE METAPARM;

      The path to the metaparms.sas file is as follows:

      • Windows: SAS-configuration-directory\Lev1\SASMeta\MetadataServer\metaparms.sas

      • UNIX and z/OS: SAS-configuration-directory/Lev1/SASMeta/MetadataServer/metaparms.sas

      The metaparms.sas file contains server connection statements that use the following syntax:

      OPTIONS METASERVER="host-name"
              METAPORT=port-number
              METAPROTOCOL="bridge"
              METAUSER="user-ID"
              METAPASS="encoded-password"
              METAREPOSITORY="Foundation";

      For an explanation of each parameter in the server connection statement, see Server Connection Statement: Reference.

      CAUTION:
      The metaparms.sas file contains the user ID and the encoded password for the SAS Administrator user. Be sure to protect this file from unauthorized access.   [cautionend]
    2. Use the following syntax to code a statement that contains the %OMABAKUP macro and its parameters:

      %OMABAKUP(DESTINATIONPATH="pathname", 
                SERVERSTARTPATH="pathname",
                RPOSMGRPATH="pathname",
                <REORG="YES|NO">, 
                <RESTORE="YES|NO">,
                <RUNANALYSIS="YES|NO">)

      For an explanation of each parameter, see %OMABAKUP Statement: Reference.

  3. Name the program BackupRepositories.sas or RestoreRepositories.sas, and save it to the metadata server startup directory, which is in the following path:

    SAS-configuration-directory/Lev1/SASMeta/MetadataServer

    Then use operating system permissions to secure the program. The permissions should deny access to anyone other than the person who will run the program.

  4. Use the appropriate command to submit the program.

    Note:   

    • %OMABAKUP must be executed on the computer that hosts the metadata server.

    • In the commands that are shown in this step, SAS-installation-directory is the directory where SAS Foundation is installed (for example, the directory might be C:\Program Files\SAS\SASFoundation\9.2 on Windows or /usr/local/SAS/SASFoundation/9.2 on UNIX).

    • Line breaks have been inserted in the commands for presentation purposes. When you enter the commands, you must omit the line breaks.

      [cautionend]

    To execute the program on Windows, submit one of the following commands:

    "SAS-installation-directory\sas.exe" 
    -config "SAS-configuration-directory\Lev1\SASMeta\sasv9.cfg"
    -sysin BackupRepositories.sas "SAS-installation-directory\sas.exe" -config "SAS-configuration-directory\Lev1\SASMeta\sasv9.cfg" -sysin RestoreRepositories.sas

    To execute the program on UNIX, submit one of the following commands:

    "SAS-installation-directory/sas" 
    -config "SAS-installation-directory/sasv9.cfg"
    -sysin BackupRepositories.sas
    "SAS-installation-directory/sas"
    -config "SAS-installation-directory/sasv9.cfg"
    -sysin RestoreRepositories.sas

    To execute the program on z/OS under the UNIX shell, submit one of the following commands:

    SAS-installation-directory/sas.sh 
    -sysin SAS-configuration-directory/Lev1/SASMeta/
    MetadataServer/BackupRepositories.sas
    -log SAS-configuration-directory/Lev1/SASMeta/
    MetadataServer/BackupRepositories.log
    -print SAS-configuration-directory/Lev1/SASMeta/
    MetadataServer/BackupRepositories.lst SAS-installation-directory/sas.sh
    -sysin SAS-configuration-directory/Lev1/SASMeta/
    MetadataServer/RestoreRepositories.sas
    -log SAS-configuration-directory/Lev1/SASMeta/
    MetadataServer/RestoreRepositories.log
    -print SAS-configuration-directory/Lev1/SASMeta/
    MetadataServer/RestoreRepositories.lst

    Alternatively, you can set up the program to be executed by a scheduling utility that is supplied by the operating system.

  5. Be sure to include the backup destination in your site's daily backups.


Example: Program for Full Backup

The following example program backs up the repository manager, each repository that is registered in the repository manager, and the metadata server's configuration files (including omaconfig.xml, adminUsers.txt, trustedUsers.txt, and logconfig.xml).

/* The metaparms.sas file contains the server connection options, including
the user ID and the encoded password for the SAS Administrator user.
Be sure to protect this file from unauthorized access. */ filename metaparm
"SAS-configuration-directory\Lev1\SASMeta\MetadataServer\metaparms.sas"; %include metaparm; /* This %OMABAKUP command creates a backup on the local machine in SAS-configuration-directory\Lev1\SASMeta\MetadataServer\SASBackup */ %omabakup(DestinationPath=
"SAS-configuration-directory\Lev1\SASMeta\MetadataServer\SASBackup", ServerStartPath="SAS-configuration-directory\Lev1\SASMeta\MetadataServer", RposmgrPath="rposmgr")

Note:   The preceding example uses paths that are appropriate for Windows systems. Use paths that are appropriate for your operating environment.  [cautionend]

During installation, the SAS Deployment Wizard created a similar backup program for your deployment (see Running the backupServer.sas and restoreServer.sas Programs). The program is called backupServer.sas and is located in SAS-configuration-directory/Lev1/SASMeta/MetadataServer.


Example: Backup Program on Windows, Using Alternating Destinations

This example program creates one backup image on the local machine and seven days of backup images on machine D2345. As a result, multiple restoration options are available if the backups become corrupted. The example includes two executions of %OMABAKUP:

/* The metaparms.sas file contains the server connection options */
filename metaparm 
"SAS-configuration-directory\Lev1\SASMeta\MetadataServer\metaparms.sas"; %include metaparm; /* This %OMABAKUP command creates a backup on the local machine in SAS-configuration-directory\Lev1\SASMeta\MetadataServer\SASBackup */ %omabakup(DestinationPath=
"SAS-configuration-directory\Lev1\SASMeta\MetadataServer\SASBackup", ServerStartPath="SAS-configuration-directory\Lev1\SASMeta\MetadataServer", RposmgrPath="rposmgr") /*Daily backups are stored at different locations on a D2345 machine, depending on the day of the week*/ data _null_; /* Function to get the day of the week */ dayofweek = weekday(date()); /* Using the case and select statement for the day of the week */ select (dayofweek); when (1) call symput("day","Sun"); when (2) call symput("day","Mon"); when (3) call symput("day","Tue"); when (4) call symput("day","Wed"); when (5) call symput("day","Thu"); when (6) call symput("day","Fri"); when (7) call symput("day","Sat"); otherwise; end; run; %put _user_; %put &day; /*This command creates backups on the D2345 machine */ %omabakup(DestinationPath="\\D2345\Dmt01 Repos Backups\&day", ServerStartPath="SAS-configuration-directory\Lev1\SASMeta\MetadataServer", RposmgrPath="rposmgr")

Note:   The preceding example uses paths that are appropriate for Windows systems. Use paths that are appropriate for your operating environment.  [cautionend]


Example: Program to Restore All Repositories and the Repository Manager

The following is an example of a program that restores the repository manager, all registered metadata repositories, and the metadata server's configuration files.

Note:   In SAS 9.1.3, the RESTORE option of %OMABAKUP did not restore the repository manager when it was run in its default mode. In SAS 9.2, the RESTORE option restores the repository manager, all registered repositories, and the metadata server's configuration files by default.  [cautionend]

/* The metaparms.sas file contains the server connection options */
filename metaparm 
"SAS-configuration-directory\Lev1\SASMeta\MetadataServer\metaparms.sas"; %include metaparm; /* This %OMABAKUP command restores the repositories from the backup files on the local machine in SAS-configuration-directory\Lev1\SASMeta\MetadataServer\SASBackup */ %omabakup(DestinationPath=
"SAS-configuration-directory\Lev1\SASMeta\MetadataServer\SASBackup", ServerStartPath="SAS-configuration-directory\Lev1\SASMeta\MetadataServer", RposmgrPath="rposmgr", Restore=Y)

Note:   The preceding example uses paths that are appropriate for Windows systems. Use paths that are appropriate for your operating environment.  [cautionend]

During installation, the SAS Deployment Wizard created a similar restore program for your deployment. For details, see Running the backupServer.sas and restoreServer.sas Programs.

Previous Page | Next Page | Top of Page