rsync; filtering rules are being ignored

2 posts / 0 new
Last post
matoo
Offline
Last seen: 7 years 9 months ago
Joined: 27.02.2013 - 20:52
rsync; filtering rules are being ignored

Hi,

I've hard time figuring out filtering behavior of my backup script. The script I'm using:

@echo off

REM # swrsync settings >>>

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

REM # <<< cwrsync settings

SET KEY=/path/to/keyfile
SET LOG="/cygdrive/d/log/sys-backup-%date:~-4,4%%date:~-10,2%%date:~-7,2%.log"

SET ARCHIVE_FILE=/cygdrive/d/bin/backup/sys-contents

SET SRC="/cygdrive/d/"
SET DST="user@server.name:/contents/D/"

rsync -avzH --delete ^
    --log-file=%LOG% ^
    -e "ssh -2i %KEY%" ^
    --filter='merge, %ARCHIVE_FILE%' ^
    %SRC% %DST%

@echo on

 

with the content file:

+ /bin
+ /bin/backup/
- *

I'd expect that only D:\bin\backup directory is synced to remote server. But for some reason the whole D:\ is selected by the filtering rule. It's easy to do it with --include option, but this is just a test for more complex filtering rule. I went through the rsync man page but I can't see what I'm missing :(

Thanks for any hints,

Martin

matoo
Offline
Last seen: 7 years 9 months ago
Joined: 27.02.2013 - 20:52
I was able to achieve

I was able to achieve d:\bin\backup directory to be synced with the following content file:

+ /bin/
+ /bin/backup/***
- *

I thought + /bin/backup would automatically include the directory and no other filter would be applied. It seems though that even if I say +/dir , -* still applies to dirs/files under it. That's why I had to use *** to go all the way down in bin/backup directory.