This tip will show you how to augment the pmrep command's ...



Informatica Backups

Getting Started

Using the PowerCenter command pmrep to backup repository contents is a relatively simple task.   First you connect to the repository and then execute the "backup" function of the pmrep command.

Here are a few suggestions to make your backup script more functional:

Use the PowerCenter repository name and system date as part of the backup file's name 

Schedule the backup to run nightly

Delete or archive old backups

Using Repository Name and System Date As The Back File Name

pmrep backup function's syntax:

pmrep backup -o file_name.rep

In its simplest form the only option you have to supply the backup function is the file name for the backup (it is a good idea to include the .rep extension in the file name).  If you do not specify a path in the file name, the output defaults to folder:

\server\infa_shared\Backup

Location:

C:\Informatica\PowerCenter8.6.0\client\bin

Informatica Repository Backup

pmrep connect -r Repo name -n User_name -x Pass -h host -o Port

connect –r dw_Training –d Domain_user-6ca950f423 –n Administrator –x Administrator

pmrep backup -o filename.rep

For maximum clarity in naming your backup files, combine the repository name environment variable with a variable containing the date.  This simple line of script will create a variable containing the system date in year, month, day format:

for /F "tokens=2-4 delims=/ " %%i in ('date /t') do set yyyymmdd=%%k_%%i_%%j

When specifying a name for the backup file, combine your repository name variable and date variable as shown in this example:

pmrep backup %INFA_REPOSITORY%_%yyyymmdd%.rep

Using an effective naming convention as the one I've demonstrated helps you organize your backups and removes any guessing when a file is needed for restoration.

Backup Repository UNIX Script

NOTE!!!!!!!!! Rename this file to repository_backup.bat and change line 26 so it references the location of the DeleteFilesByAge.vbs files !!!!!!!!!!!!!!!!!!

rem ==================================================================================

rem = This batch files preforms a Repository backup of the Informatica repository

rem = The Informatica supplied cmd PMREP is used to iniate the backup, unless otherwise

rem = specified, output from the backup will default to %INFA_PATH%\server\infa_shared\Backup

rem =

rem = Example using a backup folder other than the default

rem = SET OUTPUT_PATH=D:\Archive\pmrep_cmd\temp

rem = pmrep backup -o %OUTPUT_PATH%\backups\%INFA_REPOSITORY%_%yyyymmdd%.rep

rem =

rem ==================================================================================

SET PATH=%INFA_PATH%\server\bin;%PATH%

rem -- Step 1 - get the date and parse it so it can be used as part of the backup file name

for /F "tokens=2-4 delims=/ " %%i in ('date /t') do set yyyymmdd=%%k_%%i_%%j

rem -- Step 2 - connect to the repository

pmrep connect -r %INFA_REPOSITORY% -d %INFA_DEFAULT_DOMAIN% -n %INFA_PM_USER% -X INFA_PM_PASSWORD >log.txt

rem -- Step 3 - issue backup option - the pmrep backup automatically uses the default PowerCenter backup folder

pmrep backup -o %INFA_REPOSITORY%_%yyyymmdd%.rep >>log.txt

rem -- Step 4 - Delete old backups

DeleteFilesByAge.vbs %INFA_PATH%\server\infa_shared\Backup 14 >>log.txt

rem -- last step

echo -- Batch file has ended -- >>log.txt

Schedule the Backup to Run Nightly

Once you have a working script, you should schedule it to run as often as required, nightly, weekly, etc.  Your company's job scheduler of choice should be sufficient to do the job.

Whatever job schedule you use, after a few weeks of running repository backups you will soon notice an abundant number of backup files accumulating on your server.  You can automate the archiving (or deletion) of these old files.

Deleting Old Backups – UNIX Script

'----------------------------------------------------------------------------------

'script to delete files from a folder

'WARNING PLEASE READ: Once a file is deleted, it will not be in the Recycle Bin.

'----------------------------------------------------------------------------------

Dim objFSO, objobjFSO, objFolder, objFile, inFolderPath, inDaysToAge

'input parameters

inFolderPath = CStr(Wscript.Arguments(0)) ' example D:\Test_Folder

inDaysToAge = CInt(Wscript.Arguments(1)) ' example 14

Set objFSO = createobject("Scripting.FileSystemObject")

'Set objFolder = objFSO.GetFolder("D:\Test_Folder") 'example of explicitly defined value

Set objFolder = objFSO.GetFolder(inFolderPath)

For Each objFile In objFolder.files

If DateDiff("d", objFile.DateLastModified,Now) > inDaysToAge Then

objFile.Delete True

End If

Next

Set objFSO = Nothing

Set inFolderPath = Nothing

Set inDaysToAge = Nothing

' end of script

' use these echo statments for debugging, place them in the FOR loop

' WScript.Echo objFile.DateCreated

' WScript.Echo Now

' WScript.Echo inFolderPath

' WScript.Echo inDaysToAge

'Alternate date evaluation - if you need to delete a file based on modified date or last accessed date vs DateCreated

' If DateDiff("d", objFile.DateLastModified,Now) > inDaysToAge Then

' If DateDiff("d", objFile.DateLastAccessed,Now) > inDaysToAge Then

Another Backup Shell Script:

#!/usr/bin/ksh

# Usage : bkp_rep.sh --repository name

REP=$1

REPUSER=repository user name

REPPWD=repository pwd

cd /opt/informatica/server/bin/  > /opt/informatica/server/bin/backup/$REP.rep

HOST=`hostname`

pmrep connect -r $REP -n $REPUSER -x $REPPWD -h $HOST -o 5001

# Check Status

STATUS=$?

if [ $STATUS -ne 0 ]

then

echo '[ERROR] : Repository Connection Failed'

return $STATUS

fi

# Backup Repository

FILENAME='Backup/'$REP

pmrep Backup -o $FILENAME -d backup -f -b -j -q

# Cleanup

pmrep cleanup

# Compress File

compress -f /opt/informatica/server/bin/Backup/$REP.rep

Taking backup from Admin console in Windows

You can take backup from your Administration Console. You must have privileges to do that.

Regularly back up repositories to prevent data loss due to hardware or software problems. When you back up a repository, the Repository Service saves the repository in a binary file, including the repository objects, connection information, and code page information. If you need to recover the repository, you can restore the content of the repository from this binary file.

Backing Up a Repository

When you back up a repository, the Repository Service stores the file in the backup location you specify for the node. You specify the backup location when you set up the node. View the general properties of the node to determine the path of the backup directory. The Repository Service uses the extension .rep for all repository backup files.

To back up a repository:

1. In the Navigator, select the Repository Service for the repository you want to back up.

2. In the Actions list, select Back Up Contents.

3. Enter a repository user name and password.

The repository user must have the Admin Repository or Super User privilege to perform backups.

4. Enter a file name and description for the repository backup file.

Use an easily distinguishable name for the file. For example, if the name of the repository is DEVELOPMENT, and the backup occurs on May 7, you might name the file DEVELOPMENTMay07.rep. If you do not include the .rep extension, the Repository Service appends that extension to the file name.

5. If you use the same file name that you used for a previous backup file, select whether or not to replace the existing file with the new backup file.

To overwrite an existing repository backup file, select Replace Existing File. If you specify a file name that already exists in the repository backup directory and you do not choose to replace the existing file, the Repository Service does not back up the repository.

6. Choose to skip or back up workflow and session logs, deployment group history, and MX data. You might want to skip these operations to increase performance when you restore the repository.

7. Click OK.

The results of the backup operation appear in the activity log.

 

Viewing a List of Backup Files

 

You can view the backup files you create for a repository in the backup directory where they are saved. You can also view a list of existing backup files in the Administration Console.

To view the list of backup files:

1. In the Navigator, select the Repository Service for a repository that has been backed up.

2. In the Actions list, select View Backup Files.

A list of the backup files appears.

 

Informatica - Best Practices

  - HOW TO: Take repository backup on weekly basis

  - HOW TO: Retain multiple session and workflow log files in the session log folder

  - HOW TO: Renaming Informatica Repository Name

 

HOW TO: Take Informatica repository backup on a daily basis

[pic]

 

It is always recommended to take full backup of development repository on a daily basis and keep it at least for a week period, so that in case of accidental deletion of mapping it can be restored from the backup. Please enable JavaScript to view this page content properly.

 

Basic batch program that automatically takes repository backup and zip the backup and keep it for a week duration:-

REM ----------------------------------------------------------

REM --SET VARIABLES

REM ----------------------------------------------------------

set LOGFILENM=

set REP=

set USER=Administrator

set PWD=

set BKPPATH=Drive:\

Set DAY=%DATE:~0,3%

REM ----------------------------------------------------------

ECHO. |TIME > %LOGFILENAME%.log

ECHO "Backup Started & Connecting to Repository" >> %LOGFILENAME%.log

pmrep connect -r %REP% -n %USER% -x %PWD% -h DEVMAX -o 5001

ECHO "Repository Connected" >> %LOGFILENAME%.log

pmrep Backup -o %BKPPATH%%LOGFILENAME%_%DAY%.rep -f -b -j -q

ECHO. |TIME >> %LOGFILENAME%.log

ECHO "Backup Completed" >> %LOGFILENAME%.log

zip -r -9 -S -m %LOGFILENAME%_%DAY%.rep.zip %LOGFILENAME%_%DAY%.rep

ECHO "Zipping complete!!!" >> %LOGFILENAME%.log 

 

Example If LOGFILENM = DV_REP then Output of the above script will be DV_REP_Mon.zip

 

The above batch program on Informatica server can be scheduled to run in night on a daily basis.

 

 

HOW TO: Retain multiple session and workflow log files in the session log folder

[pic]

 

You can set sessions to retain log files according to the following options:

Session Runs. The Integration Service creates a designated number of session log files. Configure the number of session logs in the Save Session Log for These Runs option. The Integration Service does not archive binary logs.

Session Time Stamp. The Integration Service creates a log for all sessions, appending a time stamp to each log. When you save a session log by time stamp, the Integration Service archives the binary logs and text log files.

To retain multiple session and workflow log files in the session log folder edit the default session configuration as follows:

1.     Open the Workflow Manager.

2.     Select Tasks > Session Configuration > Edit Please enable JavaScript to view this page content properly.

3.     Click the Properties tab.

4.     For Save Session log by select Session runs or Session timestamp from the list

5.     Optional. If you selected Session runs in step 4, enter a numeric value for the Save session log for these runs attribute:

 

[pic]

 

Note:

These settings will take effect for new sessions you create.

For old existing sessions you will get the Revert option.

 

If you click on Revert, then it will take your modified configuration file settings.

 

 

[pic]

 

This change will be applicable to all the new sessions.

| | |

| | |

$PMSessionLogCount Integration Service Variable

You can also use the $PMSessionLogCount service variable to create the configured number of session logs for the Integration Service.

1.     Go to Administration Console.

2.     Go to the Integration Service > Properties > General Properties.

3.     Set the value $PMSessionLogCount.

In this example it is set to 2 which will keep a history of 3 (2+1) log files.

 

 

[pic]

 

  

4.     Open the Workflow Manager.

5.     Select Tasks > Session Configuration > Edit.

6.     Select the Properties tab.

7.     Use of variable $PMSessionLogCount set in the Administration Console:

 

 

[pic]

 

 

 

HOW TO: Renaming Informatica Repository Name

There may be cases when you would like to rename Informatica Repository, the effective way of doing as follows -

 

Make sure while performing following operation, none of the developers are connected to Informatica Repository.

Step 1: Using Repository Server Administration - Create repository backup: File Name “BI_Informatica_Rep” and skip workflow and session logs (this will save time and

Please enable JavaScript to view this page content properly.

space) as shown in figure 1.

[pic]

 

Figure 1: Repository Backup - Advance Options

 

Step 2: Validate the backup is created on X:\Infa_714\RepositoryServer\bin\Backup

 

Step 3: Create a copy of license file to NewName.lic from OldName.lic, the license file can be found at X:\Infa_714\RepositoryServer\bin

 

Step 4: Using Repository Server Administration – Drop the existing repository

 

Step 5: Using Repository Server Administration – Create new repository from backup the file "BI_Informatica_Rep" as shown in Figure 2

 

[pic]

 

Figure 2: Create New Repository using Restore



HOW TO: Do a repository backup using UNIX shell commands

Solution

This is an example of UNIX shell commands that can be used to do a repository backup with pmrep commands.

This requires two commands, the connect command and the backup command.

Example:

pmrep connect -r myrepserver  -n Administrator -x mypassword -h myhost -o 5001 > backuplog.out 2>1

echo “Beginning Repository backup at `date`”>> backuplog.out

pmrep backup -o backup_prod.rep  >> backuplog.out 2>1

echo “Done Repository backup at `date`”>> backuplog.out

More Information

To write the backup file to a specific directory (other than the current working directory) use the fully qualified name.

Example:

pmrep connect -r myrepserver  -n Administrator -x mypassword -h myhost -o 5001 > backuplog.out 2>1

echo “Beginning Repository backup at `date`”>> backuplog.out

pmrep backup -o /home/repobackups/ backup_prod.rep  >> backuplog.out 2>1

echo “Done Repository backup at `date`”>> backuplog.

An example of a Windows batch file to automate repository backups

Problem Description

Example of a Windows batch file for automating a repository backup using the pmrep command line utility.

Solution

The following batch file example connects to the repository then backs up the repository.

pmrep connect -r training -n training  -x training -h p156475 -o 5001

pmrep backup -o testbk -f

More Information

The pmrep command is located in the bin directory under the Repository Server installation directory.

Parameter Values:

* connect

-r

-n

-x

-h

-o

* backup

The option -o is required.

-o

-f (overwrite existing output file)

Working with the Command Prompt in informatica

PMCMD:

Use pmcmd commands with operating system scheduling tools like cron, or you can embed pmcmd commands into shell or Perl scripts.

When you run pmcmd in command line mode, you enter connection information such as domain name, Integration Service name, user name and password in each command. For example, to start the workflow “wf_SalesAvg” infolder “SalesEast,” The user, seller3, with the password “jackson” sends the request to start the workflow.

syntax:

pmcmd startworkflow -sv MyIntService -d MyDomain -u seller3 -p jackson -f SalesEast wf_SalesAvg

Command Line Mode:

1. At the command prompt, switch to the directory where the pmcmd executable is located.

By default, the PowerCenter installer installs pmcmd in the \server\bin directory.

2. Enter pmcmd followed by the command name and its required options and arguments:

pmcmd command_name [-option1] argument_1 [-option2] argument_2...

Interactive Mode :

1. At the command prompt, switch to the directory where the pmcmd executable is located. By default, the PowerCenter installer installs pmcmd in the \server\bin directory.

2. At the command prompt, type pmcmd.This starts pmcmd in interactive mode and displays the pmcmd> prompt. You do not have to type pmcmd before each command in interactive mode.

3. Enter connection information for the domain and Integration Service.

For example:

connect -sv MyIntService -d MyDomain -u seller3 -p jackson

4. Type a command and its options and arguments in the following format:command_name [-option1] argument_1 [-option2] argument_2...pmcmd runs the command and displays the prompt again.

5. Type exit to end an interactive session.

For example, the following commands invoke the interactive mode, establish a connection to Integration Service“MyIntService,” and start workflows “wf_SalesAvg” and “wf_SalesTotal” in folder “SalesEast”:

pmcmd

pmcmd> connect -sv MyIntService -d MyDomain -u seller3 -p jackson

pmcmd> setfolder SalesEast

pmcmd> startworkflow wf_SalesAvg

pmcmd> startworkflow wf_SalesTotal

Scripting pmcmd Commands :

For example, the following UNIX shell script checks the status of Integration Service “testService,” and if it is running, gets details for session “s_testSessionTask”:

#!/usr/bin/bash

# Sample pmcmd script

# Check if the service is alive

pmcmd pingservice -sv testService -d testDomain

if [ "$?" != 0 ]; then

# handle error

echo "Could not ping service"

exit

fi

# Get service properties

pmcmd getserviceproperties -sv testService -d testDomain

if [ "$?" != 0 ]; then

# handle error

echo "Could not get service properties"

exit

fi

# Get task details for session task "s_testSessionTask" of workflow

# "wf_test_workflow" in folder "testFolder"

pmcmd gettaskdetails -sv testService -d testDomain -u Administrator -p adminPass -folder testFolder -

workflow wf_test_workflow s_testSessionTask

if [ "$?" != 0 ]; then

# handle error

echo "Could not get details for task s_testSessionTask"

exit

fi

Schedule Workflow

Instruct the Integration Service to schedule a workflow. Use this command to reschedule a workflow that has been removed from the schedule.

The ScheduleWorkflow command uses the following syntax in the command line mode:

pmcmd ScheduleWorkflow

[]

[ folder]

workflow

FREQUENTLY USED PMCMD COMMANDS IN INFORMATICA

type csh command and then source your file .csh source .cshrc_infa

and then run pmcmd command

synatx is as follows

pmcmd scheduleworkflow [host:]portno [ folder] workflow

--------------------------------- pmcmd startworkflow -sv Integartion service name -d domain -u username -p password -f 'folder' workflow name

If you are alreadyin pmcmd prompt then follow the below mentioned steps

The following commands were helpful for pmcmd:

pmcmd>connect -sv Service -d domain -u username -p password

pmcmd>startworkflow -f 'folder' workflow

pmcmd>getworkflowdetails -f 'folder' -rin workflow

pmcmd>gettaskdetails -f 'folder' workflow

pmcmd>stoptask -f 'folder' workflow

pmcmd>getsessionstatistics -f 'folder' workflow

pmcmd>scheduleworkflow -f 'folder' workflow

pmcmd>unscheduleworkflow -f 'folder' workflow

pmcmd>disconnect -sv Service -d domain -u username -p password

pmcmd> connect -sv IN_Training -d Domain_user-6ca950f423 -u Administrator -p Adm

inistrator

Connected to Integration Service: [IN_Training].

pmcmd> getrunningsessionsdetails

Integration Service status: [Running]

Integration Service startup time: [Wed Aug 24 01:35:43 2011]

Integration Service current time: [Sun Aug 28 15:01:34 2011]

Number of active sessions on this Integration Service: [0]

pmcmd> getservicedetails

Integration Service status: [Running]

Integration Service startup time: [Wed Aug 24 01:35:43 2011]

Integration Service current time: [Sun Aug 28 15:02:21 2011]

Number of scheduled workflows on this Integration Service: [0]

Number of active workflows on this Integration Service: [0]

Number of active sessions on this Integration Service: [0]

Number of waiting sessions on this Integration Service: [0]

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download