473,513 Members | 2,661 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

bash shell version of db2uext2 (DB2 USEREXIT),backup archive log to remote host!

5 New Member

How to automate backup archive log to remote host?


Using the IBM supplied UserExit sample program db2uext2.cdisk? It's too complex and allways is error while compiling.


So I decide to write a bash version of db2uext2, ant it works!


1. create bash shell file
Expand|Select|Wrap|Line Numbers
  1. nano -w /home/db2inst1/sqllib/bin/db2uext2
  2.  
2. modify permissions
Expand|Select|Wrap|Line Numbers
  1. chown bin:bin /home/db2inst1/sqllib/bin/db2uext2
  2. chmod 755 /home/db2inst1/sqllib/bin/db2uext2
  3.  
3. update LOGARCHMETH1 to USEREXIT
Expand|Select|Wrap|Line Numbers
  1. db2 get db cfg for DBNAME | grep LOGARCH
  2. db2 update db cfg for DBNAME using LOGARCHMETH1 USEREXIT
  3.  
4. wait or restart db2 immediately


===========================================
db2uext2 script
===========================================
Expand|Select|Wrap|Line Numbers
  1. #!/bin/bash  
  2. #db2uext2 -OSLinux -RLSQL07020 -RQARCHIVE -DBDBNAME -NN0 -LP/data/archlog/ -LNS0000123.LOG  
  3. #copy archived log file to remote host, do not delete local log file!!!  
  4. #do not delete local log file!!!  
  5.  
  6. RHOST=192.168.0.180  
  7. RROOT=/data/backup/  
  8.  
  9. LROOT=/data/archlog/  
  10.  
  11. DIR=/opt/admin/db2  
  12. LOG=$DIR/log/archive-log.log  
  13.  
  14. RQ=""  
  15. DB=""  
  16. LP=""  
  17. LN=""  
  18.  
  19. for arg in "$@"  
  20. do  
  21.     opt=${arg:1:2}  
  22.     val=${arg:3}  
  23.  
  24.     if   [ "$opt" = "RQ" ]; then  
  25.         RQ="$val"  
  26.     elif [ "$opt" = "DB" ]; then  
  27.         DB="$val"  
  28.     elif [ "$opt" = "LP" ]; then  
  29.         LP="$val"  
  30.     elif [ "$opt" = "LN" ]; then  
  31.         LN="$val"  
  32.     fi  
  33. done  
  34.  
  35. now=`date +'%Y-%m-%d %H:%M:%S'`  
  36. today=`date +%Y-%m-%d`  
  37.  
  38. LPATH=$LROOT$DB/archlog/  
  39. LFILE=$LPATH$LN  
  40.  
  41. if [ "$RQ" = "ARCHIVE" ]; then  
  42.     if [ ! -d $LPATH ]; then  
  43.         echo create local archive log path $LPATH  
  44.         mkdir -p $LPATH >> $LOG  
  45.     fi  
  46.  
  47.     scp $LP$LN $LPATH  >> $LOG  
  48.  
  49.     RPATH=$RROOT$DB/$today/archlog  
  50.  
  51.     message="$now move $LFILE -> $RHOST:$RPATH"  
  52.  
  53.     ssh $RHOST mkdir -p $RPATH >> $LOG  
  54.     rsync -q -auPv $LFILE $RHOST:$RPATH >> $LOG  
  55.  
  56.     rm $LFILE  
  57.  
  58.     #echo $message  
  59.     echo $message >> $LOG  
  60. else  
  61.     echo RESTORE  
  62. fi
  63.  
===========================================
http://blog.csdn.net/caviler/article/details/19562387
Feb 20 '14 #1
0 1627

Sign in to post your reply or Sign up for a free account.

Similar topics

3
8238
by: John Bowling | last post by:
I have a java (2.0) program with the following lines: String cmdArray1 = {"lp", "-d", "hp4m", "MyFile"}; System.out.println(Runtime.getRuntime().exec(cmdArray1)); It compliles properly, but...
3
15980
by: brianj | last post by:
I have an older version of Cygwin (B20) under which "make" works fine. I recently installed the latest version of Cygwin. When I type "make" at the command prompt, I get the message: bash:...
0
1677
by: Johann Blake | last post by:
I am using the TcpClient to connect to a web site. I then open a NetworkStream and read the contents that are being sent back. The problem is that I have no idea when the remote host is finished...
2
2180
by: Jeff | last post by:
I have an ASP.NET web page accessing a SQL database. I've used VS to build the app and stored it in the eNPTest02 directory of my localhost on my development machine. The database is on the web. ...
4
3878
by: cpptutor2000 | last post by:
Could some C guru help me please? I am using the following program to open a SSH connection to a remote host and eventually run a program on that remote host. #include <stdio.h> #include...
16
3919
by: John Salerno | last post by:
Hi all. I just installed Ubuntu and I'm learning how to use the bash shell. Aside from the normal commands you can use, I was wondering if it's possible to use Python from the terminal instead of...
1
1969
by: aj | last post by:
DB2 LUW 8.2 FP14 Red Hat AS 2.1 Anyone know what error rc 2 means for a userexit log archive? Googling has not helped.... 2007-01-24-15.14.54.228678-300 I476363G371 LEVEL: Warning...
0
2963
by: kukluxklan | last post by:
hi all, im tring to implement a bash shell with some operations like(pipe,redirection etc).im using execvp system call to achieve this.im stuck at redirecting the outut of a command to a file.the...
1
9210
by: malooga | last post by:
Hello, I'm having a problem connecting to DB2 on a remote iSeries host from a Linux server, both of which reside on my company's internal network. I'm using the IBM Linux Client V9.1. When I try...
0
7257
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7157
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5084
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1591
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.