#!/bin/bash PATH="/bin:/usr/bin:/usr/ucb:/usr/sbin:/usr/local/bin" export PATH LOG=/oracle/rsync/sync.log SEM=/oracle/rsync/sem SRC=/oracle/oraarch DEST=rsync://backup/arc/ 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