| Using the %OMABAKUP Macro to Perform Backups and Restores |
| Write and Execute an %OMABAKUP Program for Windows or UNIX |
Use the following steps to execute %OMABAKUP on Windows or UNIX:
If you are performing a backup, first create and secure a directory in the path where the backup files will be stored. For Windows, the following path is recommended:
C:\SAS\config-dir-name\Lev1\SASBackup
For Unix, the following path is recommended:
installer's-home-dir/SAS/config-dir-name/Lev1/SASBackup
Note: The
full pathname of a backup repository cannot exceed 200 characters. ![[cautionend]](../common.hlp/images/cautend.gif)
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.
Create a SAS program with a server connection statement and the %OMABAKUP macro, as follows:
Use the following syntax to code a server connection statement:
options metaserver="localhost" metaport=port-number metaprotocol=bridge metauser="administrative-userID" metapass="encoded-password" metarepository="Foundation";
For an explanation of each parameter, see Server Connection Statement: Reference.
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.
Name the program BackupRepositories.sas or RestoreRepositories.sas, and save it to the directory where the SAS Metadata Server is started. For default Windows installations, the path is as follows:
C:\SAS\config-dir-name\Lev1\SASMain
For default Unix installations, the path is as follows:
installer's-home-dir/SAS/config-dir-name/Lev1/SASMain
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.
If you specified Restore="Yes", and if repository auditing is enabled on any of your repositories, follow these steps before you run the program:
Disable repository auditing on each repository. For instructions, see Administering the SAS Metadata Server Audit Trail.
Prepare an empty audit path location that will be used after the restore is complete. You can do either of the following:
If you want to resume using the same audit directory after the restore is complete, then move the current audit files to a different location.
If you want to specify a different audit directory after the restore is complete, then create the new directory.
To execute the program on Windows, submit one of the following commands:
"SAS-install-dir\sas.exe" BackupRepositories.sas "SAS-install-dir\sas.exe" RestoreRepositories.sas
To execute the program on Unix, submit one of the following commands:
"SAS-install-dir/sas" BackupRepositories.sas "SAS-install-dir/sas" RestoreRepositories.sas
Alternatively, you can set up the program to be executed by a scheduling utility that is supplied by the operating system.
If you specified Restore="Yes", you can re-enable repository auditing for each repository after the restore is completed. Be sure to specify an empty directory as the audit path location (see step 4).
| Error Logging on Windows or UNIX |
On UNIX and Windows systems, errors are written to a file named BackupRepositories.log in the directory where the %OMABAKUP program was executed.
| Example: Program for Full Backup on Windows |
The following example program creates a full backup of the metadata server, including the repository manager and each repository that is registered in the repository manager.
/* These system options establish a connection to the metadata server */
options metaserver="D1234"
metaport=8561
metaprotocol="bridge"
metauser="administrative-userID"
metapass="encoded-password"
metarepository="Foundation";
/* This %OMABAKUP command creates a backup on the D1234 machine in
C:\SAS\config-dir-name\Lev1\SASBackup */
%omabakup(DestinationPath="C:\SAS\config-dir-name\Lev1\SASBackup",
ServerStartPath="C:\SAS\config-dir-name\Lev1\SASMain",
RposmgrPath="metadataServer\rposmgr")
| Example: Backup Program on Windows, Using Alternating Destinations |
This example program creates one backup image on machine D1234 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 first execution stores the backup files on the metadata server host (D1234). These backup files are overwritten every day, and they represent the most recent backup image.
The second execution stores the backup files on a different machine (D2345). The name of the backup directory varies depending on the day of the week. The backup directory is specified as Dmt01 Repos Backups\&day, where &day is a directory named Sun, Mon, Tue, Wed, Thu, Fri, or Sat.
/* These system options establish a connection to the metadata server */
options metaserver="D1234"
metaport=8561
metaprotocol="bridge"
metauser="administrative-userID"
metapass="encoded-password"
metarepository="Foundation";
/* This %OMABAKUP command creates a backup on the D1234 machine in
C:\SAS\config-dir-name\Lev1\SASBackup */
%omabakup(DestinationPath="C:\SAS\config-dir-name\Lev1\SASBackup",
ServerStartPath="C:\SAS\config-dir-name\Lev1\SASMain",
RposmgrPath="MetadataServer\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="C:\SAS\config-dir-name\Lev1\SASMain",
RposmgrPath="MetadataServer\rposmgr")
| Example: Program on Windows to Restore Only the Repository Manager |
The following example program restores only the repository manager.
If the repository manager on your metadata server does not contain active registrations for all of the repositories that you want to restore (for example, if a repository was accidentally deleted through a SAS Management Console command since the last backup was taken), you must run this program first before you can successfully restore your repositories. For more information, see Restoring the Repository Manager.
/* These system options establish a connection to the metadata server */
options metaserver="D1234"
metaport=8561
metaprotocol="bridge"
metauser="administrative-userID"
metapass="encoded-password"
metarepository="Foundation";
/* This %OMABAKUP command restores the repository manager from the backup
files on the D1234 machine in
C:\SAS\config-dir-name\Lev1\SASBackup */
%omabakup(DestinationPath="C:\SAS\config-dir-name\Lev1\SASBackup",
ServerStartPath="C:\SAS\config-dir-name\Lev1\SASMain",
RposmgrPath="metadataServer\rposmgr",
Restore=Y,
RepositoryList="REPOSMGR")
| Example: Program on Windows to Restore All Repositories |
The following example program restores all registered repositories, but it does not restore the repository manager.
Use this program if you are certain that the server's repository manager contains active registrations for all of the repositories that you want to restore. If it does not, then you must restore the repository manager first as a separate step. For detailed guidance, see Restoring the Repository Manager.
/* These system options establish a connection to the metadata server */
options metaserver="D1234"
metaport=8561
metaprotocol="bridge"
metauser="administrative-userID"
metapass="encoded-password"
metarepository="Foundation";
/* This %OMABAKUP command restores the repositories from the backup
files on the D1234 machine in
C:\SAS\config-dir-name\Lev1\SASBackup */
%omabakup(DestinationPath="C:\SAS\config-dir-name\Lev1\SASBackup",
ServerStartPath="C:\SAS\config-dir-name\Lev1\SASMain",
RposmgrPath="metadataServer\rposmgr",
Restore=Y)
Copyright © 2007 by SAS Institute Inc., Cary, NC, USA. All rights reserved.