Skip to main content

SAS Migration automation - Metadata folder migration using Export and Import Batch script.

Below steps are specific for metadata User folder migration, but can be used for other object too.
I used MobaXterm, as DISPLAY option is not enable in Putty.

Step 1) Insert the correct user metadata folder location in user.txt at source environment.

$cat > user.txt
/Users/White, Walter
/Users/White, Skyler
/Users/White, Walter Jr.
 
Step 2) export DISPLAY. 
$export DISPLAY=ip.address
 
If we don’t  export DISPLAY, we will get below error:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
For more information, view the export log file: /home/lannister/export/log/Export_150523062423.log
The export process has failed.

Step 3) Run below script in source environment.
for i in {1..3}   /*depends on number of user */
do
/* will cut the user  location one by one from file user.txt */
j=`sed -n "$i"p user.txt`   
/* this is batch export script, and is used to create package on required objects */
/apps/sas/SASPlatformObjectFramework/9.2/ExportPackage -host source.hostname.com -port 8562 -user tyrion.lannister -password ***** -package "/home/tyrion.lannister/export/$i.spk" -objects "$j(Folder)" -subprop -log /users/tyrion.lannister/export/log    
 done
 

Step 4) you can check log once all objects are exported to check if any failed.
 
Step 5) Scp the .spk and subprop file to target location (the environment to which SAS metadata folder should be migrated).
 
Step 6) Make mapping changes (if any) in the subprop file at target location

After change:
ApplicationServer[1].SourceName=SAS92APP
ApplicationServer[1].TargetName=SAS94APP

 
Before change:
ApplicationServer[1].SourceName=SAS92APP
ApplicationServer[1].TargetName=SAS92APP 

The SAS92APP is the name used in source environment and in target environment we created the app with name SAS94APP so I am mentioning it. If the name is same in both source and target then no change is required.

Step 7) Make metadata target location entry in file user.txt
cat > user.txt

/Users/White, Walter/My Folder/old metadata
/Users/White, Skyler/My Folder/old metadata
/Users/White, Walter Jr./My Folder/old metadata

 
Step 8) use the below import scripts at target location.
** Just make sure that the order of users in target is same as source.

for i in {1..3}   /*depends on number of user */
do
/* will cut the user  location one by one from file user.txt */
j=`sed -n "$i"p user.txt`  
/apps/sas/SASPlatformObjectFramework/9.4/ImportPackage -host target.hostname.com -port 8562 -user tyrion.lannister -password ***** -package "/home/tyrion.lannister/import/$i.spk" -target "$j" -includeACL -subprop -newOnly -log /users/tyrion.lannister/import/log    
done

 
Step 9) Check logs to find it any failed or not. Once above script is completes it means import ends. You can also verify in SAS Management Console.
 

Comments

Popular posts from this blog

How to create library for Oracle in SAS?

In this article, you will get details about creating a new library using SAS Management Console. Here, I have provided the procedure for creating library for Oracle database. However, the steps will be same for other databases like SQL server, Teradata etc.     Creating connection to Oracle database: To create library, you must first create a connection to Oracle database in your host machine. Host machine is the physical location where your SAS platform is installed. Details like Oracle database hostname/IP address and DSN/SID name is needed. Those details should be entered in tsnnames.ora file. For more details check this article Creating library in SAS Management Console: The steps for creating library for Oracle using SAS Management Console (SMC) can used for other database like SQL Server, My SQL etc. New library wizard: Expand Data Library Manager plug-in, right click on the Libraries and click New Library to start library wizard.  You will be asked

SAS - CLI error trying to establish connection

Issue: User asked me to make a database connectivity to SQL Server. They provided following details SQL server hostname and ip address Database/DSN name Username Password I made entry in ODBC.ini file. You know, SQL Server entries were made in ODBC.ini and Oracle entries were made in TNS.ora file. Everything went fine, took back up of odbc.ini, made entry and saved the file. So to test this connection I ran the libname statement in SAS Enterprise Guide 6.1. It throwed following error. Error Message: My DB team showed that they are able to login   14 GOPTIONS ACCESSIBLE; 15 LIBNAME test ODBC DATASRC=SGE_DS SCHEMA=VST USER=sales PASSWORD=XXXXXXXXX; ERROR: CLI error trying to establish connection: [SAS/ACCESS to SQL Server][ODBC SQL Server Legacy Driver][SQL Server]Login failed for user 'sales'. Solution: First I suspected that Login failed for user 'sales' meant the password provided by DB team was wrong. They responded that they were able to login wi

Insufficient authorization to access PIPE error in SAS EG

Issue: When I tried to run SAS code in SAS Enterprise Guide it throws following errors: ERROR: Insufficient authorization to access PIPE. ERROR: Error in the FILENAME statement. Screenshot of error: Solution: This error occurs when you try to run OS commands in SAS code. To run the OS commands in SAS code you need to enable XCMD option. You check it in SAS Management Console by following below steps.   Open SMC -> Expand Servers -> Expand   In SASApp , expand Logical Workspace Server -> right click on Workspace Server. Click properties -> option tab -> advanced options -> launch properties. Check whether Allow XCMD is checked. The issue arises if the Allow XCMD is not checked. In above image, Allow XCMD option is not checked. It should be checked to run OS commands from SAS code. In Unix /Linux machines, this XCMD option can be enabled by using system option XCMD in sasv9 config file or workspaceserver.sh script file. Us