#!/bin/bash
PATH="/bin:/usr/bin:/usr/ucb:/usr/sbin:/usr/local/bin"
export PATH
LOG=/oracle/URP/rsync/sync.log
SEM=/oracle/URP/rsync/sem
SRC=/oracle/URP/oraarch
DEST=rsync://10.1.10.200/urparc/
RSYNC='/usr/local/bin/rsync -t'
[ -e $SEM/run ] && exit 1
touch $SEM/run
cd $SRC
for i in *.dbf
do
#if success semaphore created, bypass this file
if [ ! -e $SEM/$i ]; then
echo `date`" Sync file "$i" ..." >> $LOG
$RSYNC $i $DEST >> $LOG 2>&1
#if rsync exit code success - create success semaphore
if [ $? -eq 0 ]; then
echo "Success." >> $LOG
touch $SEM/$i
fi
fi
done
#delete semaphore for last arclog, because it maybe writing at this time, will be resynced next time
rm $SEM/`ls | sort | tail -1`
cd $SEM
#delete old semafores
for i in *.dbf
do
[ ! -e $SRC/$i ] && rm $i
done
rm $SEM/run