Link to home
Start Free TrialLog in
Avatar of Turbowy
Turbowy

asked on

Rsync - how to stop removing files if only 1 file has been synched?

Hi I am using rsync to sync files from A to B server, the script is outlined at the bottom. Normally there are about 20-50 files to transfer. Once the files are transferred then the script deletes the files from the source server by calling the rmUBBZsun2.ksh

How do i modify this script to prevent deletion of the files if only 1 file has been transferred due to interruption or network outage etc..?



@ECHO OFF

set LOG=D:/BCBCDB/BCBC_Sun2/sun2_log.txt
set FILE_LIST=D:/BCBCDB/BCBC_Sun2/sun2_file_list.txt



SETLOCAL
SET CWRSYNCHOME=%PROGRAMFILES%\CWRSYNC
SET CYGWIN=nontsec
SET HOME=%HOMEDRIVE%%HOMEPATH%
SET CWOLDPATH=%PATH%
SET PATH=%CWRSYNCHOME%\BIN;%PATH%


REM @ECHO ON
date /t > %LOG%

REM call :Logit>>%LOG% 2>&1
REM exit /b 0
REM :Logit

cd D:\BCBCDB\BCBC_Sun2\bbdb\
IF EXIST *.Z (
move /Y D:\BCBCDB\BCBC_Sun2\bbdb\*.Z D:\BCBCDB\BCBC_Sun2\bbdb\archive\ >> %LOG%
) ELSE ( echo no dumpfiles to move >> %LOG%
)


"C:\Program Files\cwRsync\bin\rsync" -av srv@sun2:/u9/oradata/bbdb/export/*.Z /cygdrive/D/BCBCDB/BCBC_Sun2/bbdb/

IF EXIST *.Z (
echo Files transferred > %FILE_LIST%
dir D:\BCBCDB\BCBC_Sun2\bbdb\*.Z /b >> %FILE_LIST%
D:\BCBCDB\bmail.exe -s mailsrv -t email@domain.com -f auto_rsync@srv.domain.com -h -a "BCBC_Sun2 BBDB Z logs archived, please

archive \\wus\BCBC_Sun2\ to DVD" -c -m %FILE_LIST%
"C:\Program Files\cwRsync\bin\ssh" wus@bcsun2 "~wus/rmUBBZsun2.ksh"
) ELSE ( echo no dumpfiles exist >> %LOG%
D:\BCBCDB\bmail.exe -s mailsrv -t email@domain.com -f auto_rsync@srv.domain.com -h -a "sun2 BBDB Z logs failed to

archive!  Please check status!"
)
ASKER CERTIFIED SOLUTION
Avatar of oheil
oheil
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Turbowy
Turbowy

ASKER

excellent