You are on page 1of 7

Working with PowerCenter repository

using Shell script


 

This paper contains sample shell scripts to perform the following tasks:

1.       Create a new PowerCenter Repository Service

2.       Backup a PowerCenter Repository Service

3.       Restore a PowerCenter Repository Service

4.       Rename a PowerCenter Repository Service

5.       Perform automatic repository backup

1. Create a new PowerCenter Repository Service

The following is a sample shell script that creates a new repository.

#-------------------------------------------------------------

# Program:          create_repo_service.sh

# Author:             Arpit Shanker

# Date::               Dec 07, 2010

# Purpose:          UNIX script to create new PowerCenter repository

#-------------------------------------------------------------

 
#-----------------------------------------------------------

# Create the Repository Service

#-----------------------------------------------------------

. $INFA_HOME/server/bin/infacmd.sh CreateRepositoryService -dn Domain_Test -un


admin -pd password -sn Test_Rep -nn node_Test

#-----------------------------------------------------------

# Connect to the Repository Service

#-----------------------------------------------------------

. $INFA_HOME/server/bin/pmrep connect -r Test_Rep -d Domain_Test

#-----------------------------------------------------------

# Create the repository contents

#-----------------------------------------------------------

. $INFA_HOME/server/bin/pmrep create -u administrator -p administrator

#-----------------------------------------------------------

# Done...

#-----------------------------------------------------------

 
 

2. Backup a PowerCenter Repository Service

The following is a sample shell script to perform backup of Powercenter repository.

#------------------------------------------------------------

# Program:          bkp_rep_service.sh

# Author:             Arpit Shanker

# Date:                 Dec 07, 2010

# Purpose:          UNIX script to perform Repository Backup

#-----------------------------------------------------------

#------------------------------------------------------------

# Declare required Variables

#-------------------------------------------------------------

UNAME= <Username>

PASSWD= <Password>

REPNAME= <Repository Name>

DOMAIN= <Domain Name>

#-----------------------------------------------------------------

# Connect to the Repository

#-----------------------------------------------------------------
 

$INFA_HOME/server/bin/pmrep connect -r $REPNAME -n $UNAME -x $PASSWD -d


$DOMAIN > $REPNAME'_bkplog.out' 2>1

echo "Repository backup started at `date`">> $REPNAME'_bkplog.out'

#-----------------------------------------------------------------

# Check the Status

#-----------------------------------------------------------------

rc=$?

if [ $rc -ne 0 ] then

echo 'ERROR!! Connect to Repository failed.....' >> $REPNAME'_bkplog.out'

return $rc

fi

#-----------------------------------------------------------------

# Start Backup...

#-----------------------------------------------------------------

$INFA_HOME/server/bin/pmrep backup -o <Path>/'bkp_'$REPNAME.rep >>


$REPNAME'_bkplog.out' 2>1

echo "Repository backup completed at `date`">> $REPNAME'_bkplog.out'

 
 

#-----------------------------------------------------------------

# Done.....

#-----------------------------------------------------------------

3. Restore a PowerCenter Repository Service

The following is a sample shell script to restore a Powercenter repository. Please note
that the target database must be empty in order to restore the repository.

#-----------------------------------------------------------------

# Program:          restore_rep_service.sh

# Author:             Arpit Shanker

# Date::               Dec 07, 2010

# Purpose:          UNIX script to restore a Powercenter repository

#----------------------------------------------------------------

#-----------------------------------------------------------

# Create New Repository Service

#-----------------------------------------------------------

. $INFA_HOME/server/bin/infacmd.sh CreateRepositoryService -dn domain_name -un


user_name -pd password -sn rep_name -nn node_name

#-----------------------------------------------------------
# Connect to the Repository Service

#-----------------------------------------------------------

. $INFA_HOME/server/bin/pmrep connect -r rep_name -d domain_name

#-----------------------------------------------------------

# Restore repository contents

#-----------------------------------------------------------

. $INFA_HOME/server/bin/pmrep restore -u user_name -p password -i <Backup File


Name>

#-----------------------------------------------------------

# Done...

#-----------------------------------------------------------

4. Rename a PowerCenter Repository Service

A Repository Service cannot be renamed directly. The following two options can be used
in order to rename the PowerCenter Repository Service. Please note that the new
repository must be created in a different database schema than the original repository.

1.       Backup and Restore

2.       Copy Repository


 

Backup and restore

1.       Backup the existing repository.

2.       Create a Repository Service with the new name.

3.       Select Actions > Restore Contents .

4.       Restore the repository backup.

Copy Repository

1.       Create a Repository Service with the new name.

2.       Select Actions > Copy Contents From.

3.       Copy the existing repository to the new Repository Service.

5. Perform automatic repository backup

If you want to automate the backup of repository at regular interval, create a workflow as
follows and schedule it to run at the desired interval.

1. Add a Command task to the workflow.


2. Call bkp_rep_service.sh script (Given in this paper) in command task to backup
the repositor

http://arpit.leading-technology.net/Informatica.htm

You might also like