troubleshooting Question

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

Avatar of Turbowy
Turbowy asked on
Storage SoftwareWindows BatchPowershell
2 Comments1 Solution839 ViewsLast Modified:
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!"
)
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros