473,654 Members | 3,022 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

bash shell version of db2uext2 (DB2 USEREXIT),backu p 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 1640

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

Similar topics

3
8252
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 does not print the file to the printer. It displays the following as the return from Runtime...: java.lang.UNIXProcess@1034bb5
3
15989
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: make: command not found I have a Makefile in the local directory and ran a ./configure script which ran successfully. So how do I configure my bash shell to recognize the make command ?
0
1691
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 sending data. It is sending a web page but it doesn't use the Content-Length header to indicate the size. While I can use the DataAvailable property, it is well known that you cannot rely on this to know when no more data is available. What I...
2
2187
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. I've found a way that works on the web, and I'm trying to get it to also work in debug mode in the IDE. The "on the web" page and my SQL database are hosted by a third party (on separate servers). Since debug mode opens IE and loads my page...
4
3885
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 <stdlib.h> int main(int argc, char* argv){ char command;
16
3931
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 the normal bash commands (e.g. print instead of echo). My main reason for asking is that I like using Python for everything, and if I don't need to learn the bash 'language', then I won't just yet. Thanks.
1
1981
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 PID : 22975 TID : 3086227136 PROC : db2logmgr (DB) INSTANCE: blah NODE : 000 FUNCTION: DB2 UDB, data protection, sqlpgRetryFailedArchive, probe:4780
0
2969
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 output im getting for the follwoing code is "*** ERROR: exec failed\n".....ny help??????????????? #include <stdio.h> #include <sys/types.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> void parse(char *line, char **argv) {
1
9261
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 to connect to the remote host using a simple connect statement, DB2 hangs. The connection statement I'm using (I've obviously obscured the parameter names): $ ./db2 connect to DATABASENAME user USERNAME using PASSWORD;
0
8375
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8290
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8815
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8593
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7306
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2714
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 we have to send another system
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1593
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.