Solved

FTP archive logs

Posted on 2004-03-31
5
408 Views
Last Modified: 2013-12-26
I am running Oracle9i on AIX RAC with 2Nodes (RS1 and RS2)
with archive mode, each oracle instant creates his own archive logs
on the first machine RS1 it creates logs1*.arc
rs1:/archive1# ls -al
-rw-r----- 1 oracle dba 104852480 Feb 19 15:37 log11740.arc
-rw-r----- 1 oracle dba 104857088 Feb 19 15:38 log11741.arc
-rw-r----- 1 oracle dba 104855040 Feb 19 15:39 log11742.arc
-rw-r----- 1 oracle dba 104856576 Feb 21 15:22 log11743.arc
-rw-r----- 1 oracle dba 23519744 Feb 23 14:32 log11744.arc
.......

and on the RS2 it creates logs2*.arc
rs2:/archive2# ls -al
-rw-r----- 1 oracle dba 104857088 Feb 25 12:59 log21271.arc
-rw-r----- 1 oracle dba 104849408 Feb 25 15:16 log21272.arc
-rw-r----- 1 oracle dba 47743488 Feb 25 15:31 log21273.arc
-rw-r----- 1 oracle dba 104857088 Feb 26 12:45 log21274.arc
-rw-r----- 1 oracle dba 104857088 Feb 26 14:41 log21275.arc
-rw-r----- 1 oracle dba 65959936 Feb 26 16:09 log21276.arc
.....

1- I want at the end of day to FTP the above files from each server
to standby AIX server to /backup folder
this folder will contain all the logs from both servers
2- now the part of file comparsion,  if the logs1*.arc and logs2*.arc already exist (the same serial no. on source and destination) on the /backup folder the script should check up for the size of the simillar files
if this log files on the /backup folder less than the orginal one .. then it should be FTP it again, if not then skip the FTP and look for another file
3- After the script has been run successfully on both server RS1 and  
and RS2 ...then it should give a report of wich files has been created
with there size..

All AIX server using KornShell as shell interface.
This FTP will be managed by oracle user

I started with this script

$host=192.168.0.1
$username=testuser
$passwd=testpwd
$file=log$seq.arc
$logdir=/archive1

#===begin ftp part===
ftp -i -n <<EOF
open $host
user $username $passwd
lcd $logdir
put $file
bye
EOF

I need some hints to end the script
I am really tired from FTP it manually


Thanks

0
Comment
Question by:madunix
  • 2
  • 2
5 Comments
 
LVL 20

Accepted Solution

by:
tfewster earned 50 total points
ID: 10726385
You won't get those sort of statistics from ftp;  One way to do it would be create trust relationships between the 2 servers (/etc/hosts.equiv and/or $ORAHOME/.rhosts)  to allow you to use rsh to get the list of files on the remote server and work out what new/changed files there are and then rcp the new/changed files.   Even better security-wise, use ssh/scp

Or get rsync which compares the contents of the specified source & target directories & distributes new & changed files automagically:
http://rsync.samba.org/download.html

(Or a really quick & sloppy way - A daily cronjob that does:
find /archive -mtime -2 -exec rcp -p {} rsX:/backup  \;    # Copy all files that changed in the last 2 days; Some files might be be copied twice, but better safe than sorry ;-)

But are you saying you want to merge the 2 lists of archive logs somehow, based on serial number?
0
 
LVL 48

Expert Comment

by:Tintin
ID: 10727427
Forget FTP.  Forget rcp.

Definitely use rsync.  It is ideal for this type of application.

0
 
LVL 25

Author Comment

by:madunix
ID: 10744523
find /archive -mtime -2 -exec rcp -p {} rsX:/backup  \;
find /archive -mtime -2 -exec rm -r {} \;

now I am using  the above, ....
later on i am gonna install a FreeBSD box and
enable rsync to backup all archive.

How can I implemet the above to work as daily cronjob
by oracle under Korn shell, where should I place it
and would be enugh to include only the above to lines to
copy then later on to rm them?
0
 
LVL 20

Expert Comment

by:tfewster
ID: 10745959
Log in as oracle, run `crontab -e` (which opens oracles crontab file for editing) and add lines
00 1 * * * find /archive -mtime -2 -exec rcp -p {} rsX:/backup  \;
00 2 * * * find /archive -mtime -2 -exec rm -r {} \;

i.e. run the copy at 1am every day, and run the delete  at 2am every day - Should be OK as long as all the files will have been copied in the hour between the 2 commands.  (All cron jobs are run using the Bourne shell, but that doesn't matter in this case).
`man crontab` for more info on the format of the crontab file
0
 
LVL 25

Author Comment

by:madunix
ID: 10746790
many thanks for the crontab. .... it works now
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
xyBalance chalenge 58 88
Host to IP 7 77
if loop in java 3 130
wordcount challenge 11 110
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now