Archive log Pull script from one server to another server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Archive log Pull script from one server to another server
# 1  
Old 01-27-2010
Archive log Pull script from one server to another server

Hi all,

Iam looking out for a shell script which pulls archive from Server A to Server B.

And at the same time, we dont want the archives which are already pulled in Server B to be removed from Server A.

Please help me on this, I have been trying on this for a quiet few time.


Thanks,
Vivek

---------- Post updated at 07:33 PM ---------- Previous update was at 07:18 PM ----------

This is on Unix servers

---------- Post updated at 07:56 PM ---------- Previous update was at 07:33 PM ----------

script needs to be executed from the Target server i.e., from Server B.
# 2  
Old 01-27-2010
Replying to your post in a constant manner like this is equivalent to bumping it up, IMO....

If you've been trying this for a while, why don't you show what you've tried already?
# 3  
Old 01-28-2010
somehow succeded by managing a script along with my colleague. Here goes the shell script:

Code:
#set -x
NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1;export NLS_LANG
ORACLE_HOME=/u02/app/oracle/product/11g/db_1;export ORACLE_HOME
PATH=.:$ORACLE_HOME/bin:/usr/local/bin:${PATH};export PATH
ORADAY=`date +%w`;export ORADAY
ORADATE=`date +"%d%h"`;export ORADATE
ORATAB=/etc/oratab;export ORATAB
# ARCHIVE_DIR is the directory that Oracle put the archive log files into defined in init.ora (Source)
ARCHIVE_DIR=/u01/app/oracle/admin/orcl/arch/test;export ARCHIVE_DIR
# ARCHIVE_COPY_DIR is the name of the directory on the target machine 
ARCHIVE_COPY_DIR=/home/oracle/Test/arch;export ARCHIVE_COPY_DIR
# find most recent file on target machine
MOST_RECENT_COPIED_FILE=`ls -1t ${ARCHIVE_COPY_DIR}/or*.dbf | head -1`;export MOST_RECENT_COPIED_FILE
echo ==\> Most Recent File in ${ARCHIVE_COPY_DIR} is ${MOST_RECENT_COPIED_FILE} \<==
#get only the file name, no path name
MOST_RECENT_COPIED_FILE_1=`echo ${MOST_RECENT_COPIED_FILE} | awk -F_ '{print $3}' -`;export MOST_RECENT_COPIED_FILE_1
MOST_RECENT_COPIED_FILE_NAME=`echo ${MOST_RECENT_COPIED_FILE_1} | awk -F. '{print $1}' -`;export MOST_RECENT_COPIED_FILE_NAME
echo Most Recent Copied File Name ${MOST_RECENT_COPIED_FILE_NAME}
# get the most recent log file
ftp -nv 134.251.61.237 << EOF
user oracle oracle12
cd /u01/app/oracle/admin/orcl/arch/test
mls orcl*.dbf /home/oracle/Test/arch/slarch.lst
y
quit
EOF
MOST_CURRENT_FILE_1=`cat slarch.lst|tail -1`;export MOST_CURRENT_FILE_1
MOST_CURRENT_FILE_2=`echo ${MOST_CURRENT_FILE_1} | awk -F_ '{print $3}' -`;export MOST_CURRENT_FILE_2
MOST_CURRENT_FILE=`echo ${MOST_CURRENT_FILE_2} | awk -F. '{print $1}' -`;export MOST_CURRENT_FILE
# we are finding the difference of archives from source and target leaving the latest one from source.  And if the difference
# is greater than zero, then there are no archives to ftp from source
diff=`expr $MOST_CURRENT_FILE - $MOST_RECENT_COPIED_FILE_NAME - 1`;export diff
if [ $diff -gt 0 ]
then
archformat1=orcl_1_;export archformat1
archformat2=.dbf;export archformat2
rm /home/oracle/Test/arch/recent_files.lis
rm /home/oracle/Test/archftpmsg.log
for ((  i = 1 ;  i <= $diff;  i++  ))
do
MOST_RECENT_COPIED_FILE_NAME=` expr $MOST_RECENT_COPIED_FILE_NAME + 1`;export MOST_RECENT_COPIED_FILE_NAME
# making the list of files to be ftp'd 
echo $archformat1$MOST_RECENT_COPIED_FILE_NAME$archformat2 >> recent_files.lis
done
# reading from recent_files.lis and ftp'ing the archives one by one
cat /home/oracle/Test/arch/recent_files.lis | while read LINE
do
sleep 90
case $LINE in
\#*) ;;
*)
FILE_TO_SEND=`echo $LINE`;export FILE_TO_SEND
echo ==\> File to send is ${FILE_TO_SEND} \<==
echo sending $FILE_TO_SEND...
ftp -n -v -i 134.251.61.237  <<EOF
user oracle oracle12
bin
cd ${ARCHIVE_DIR}
pwd
lcd ${ARCHIVE_COPY_DIR}
get ${FILE_TO_SEND}
bye
EOF
echo finished sending $FILE_TO_SEND...
esac
done
else
echo "No files to ftp" > ftpmsg.log
fi


Last edited by pludi; 01-28-2010 at 08:37 AM.. Reason: code tags, please...
# 4  
Old 01-29-2010
Use rsync
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to archive logs and sftp to another archive server

Requirement: Under fuse application we have placeholders called containers; Every container has their logs under: <container1>/data/log/fuse.log <container1>/data/log/fuse.log.1 <container1>/data/log/fuse.log.XX <container2>/data/log/fuse.log... (6 Replies)
Discussion started by: Arjun Goswami
6 Replies

2. Shell Programming and Scripting

Bash Script to pull ipa server name on 500 servers

Hello All, I need help writing a bash script that will run on 500 LINUX servers and do the following: 1. Capture the ipa_server name from /etc/sssd/sssd.conf on a list of 500 servers in the ipahosts file. 2. Write to a file outputing only server name and IPA server name. Root ssh keys... (3 Replies)
Discussion started by: vtowntechy
3 Replies

3. UNIX for Dummies Questions & Answers

Transfer file from server B to server C and running the script on server A

I have 3 servers A, B, C and server B is having some files in /u01/soa/ directory, these files i want to copy to server C, and i want to run the script from server A. Script(Server A) --> Files at Server B (Source server) --> Copy the files to Server C(Target Server). We dont have RSA key... (4 Replies)
Discussion started by: kiran_j
4 Replies

4. Shell Programming and Scripting

Script to pull uid greater than 1000 from remote server

Hello, I am trying to get UID # greater than 1000 from all linux server, I tried this script getting this error message, someone please suggest. $for i in `cat hostlist.0709.org` ; do ssh -t $i 'awk -F':' "{ if($3 >= 1000) print $0 }" /etc/passwd ' >> output ; done $ cat output hostname1... (4 Replies)
Discussion started by: bobby320
4 Replies

5. Shell Programming and Scripting

Pull only new files from Server A to Server B

Hi, I am very new to shell scripting and need to create shel script for following : Look continuously for new files in server A(/hosting/apps) and as they arrive pull it to server B (/hosting/landing). Note - only new files that have arrived in server A should be pulled into Server B.... (3 Replies)
Discussion started by: aditya16in
3 Replies

6. Shell Programming and Scripting

Connect to Server B from Server A and Archive the file

Hi I need to connect to a ServerB from Server A eg: Server A : 172.20.273.51, un: xxx, pwd: xxx Server B: 172.20.273.51, un:yyy, pwd: yyy Need to copy the files(with name starts with IME*) from /grid/pc/IME* to /grid/pc/archive What will be the command or script to... (3 Replies)
Discussion started by: vsmeruga
3 Replies

7. Shell Programming and Scripting

Script to pull Archives from Server A to Server B

Hi all, Iam looking out for a script which pulls archive logs from Server A to Server B. At the same time we donot want the archives to be deleted from Server A. Request you to please help me on this. Thanks, Vivek (1 Reply)
Discussion started by: vivi.raghav
1 Replies

8. Shell Programming and Scripting

pull files from window server to aix box

Hi All, I have a new requirment where i have to pull files from windows server to aix box. I am using scp command to pull a files. command is working fine but it is asking password for everytime i m running this command.I want to automate this so that it will not ask any password. ... (1 Reply)
Discussion started by: prasson_ibm
1 Replies

9. UNIX for Dummies Questions & Answers

Pull a file from a remote server through a shell script

Hi, I am writing a shell script to pull a file from a remote server (Let say its a windows based remote server). One of my criteria is to pull a file only if it is not empty. We have done a similar script to push a file from our end to a remote server and before pushing it we check for the... (2 Replies)
Discussion started by: sashankkrk
2 Replies

10. Solaris

Archive data accross solaris server

Can anyone tell me how to safely archive data across the network instead of tape in Solaris. Thanks Remi (1 Reply)
Discussion started by: Remi
1 Replies
Login or Register to Ask a Question