Can't get cwrsync over ssh directory exclusions to work

Posted on 2009-02-17
Last Modified: 2013-12-01
Hello all-

Here's my situation-

I have remote users with laptops who are backing up data to a central location server. The laptop clients are Windows XP, a few Vista. The backup server is Windows Server 2003 standard.

On both server and client I have installed CopSSH and cwrsync from

I have constructed batch files to run either manually initiated backup transfers, or to run as scheduled tasks. This all works really well. Transfer rates are great, etc. I've set up SSH key pairs so users do not have to enter passwords, and I have an exclusion list text file that lives on the server which is pulled down and referenced anew for every transfer.

The rsync command is backing up users' My Documents folder, and in the command, I have a path exclusion to leave out /My Documents/Exclude*

I have an exclusion for file size limit, one for excluding types from a text file, and one to exclude a directory within My Docs. This directory path exclusion will not work.

I've tried many many forms of the syntax, and with ones that are obviously wrong, I get syntax errors like I expect, but versions that are correct or should work, I get no errors or failures, but the exclusion simply doesn't work. It's like the command runs properly, but then ignores itself and sends the excluded directory anyway.

I have been searching the web for several weeks now to find a solution to no avail. I've seen several others online with similar issues who've gotten it to work, but none of the applied fixes worked in my setup.............

Any thoughts or ideas? Any help is greatly appreciated.
Batch File Example, commented line is the one that fails...


SET CYGWIN=nontsec


chdir C:\unix\Bin


"C:\unix\Bin\rsync" -avzr --delete /cygdrive/c/exclude.txt

THIS LINE FAILS TO EXCLUDE THE DIRECTORY>> "C:\unix\Bin\rsync" -avzr --progress --exclude="/cygdrive/c/Documents and Settings/username/My Documents/Exclude/*" --exclude-from="/cygdrive/c/exclude.txt" --max-size=1.5MB-1 "/cygdrive/c/Documents and Settings/username/My Documents/" -e SSH



Open in new window

Question by:scisupport
    LVL 16

    Expert Comment

    Add \ before spaces so that this

    /cygdrive/c/Documents and Settings/username/My Documents/Exclude/*

    becomes this

    /cygdrive/c/Documents\ and\ Settings/username/My\ Documents/Exclude/*

    If this doesn't work, remove the asterisk at the end of the path

    Author Comment


    Thanks for the ideas-

    I had tried already with and without the asterisk.

    I did try the escape character in the path as you suggested, but that still did not work. It didn't give any errors at all - the command appears to run successfully, but the exclusion just doesn't work...

    Any other thoughts?

    Thanks again.
    LVL 16

    Expert Comment

    what if you simply use --exclude-from option alone?

    Author Comment

    Just using the --exclude-from=exclude.txt works for files. Any file types that are listed there are not transferred- *.exe, *.msi, etc.

    I tried adding the directory path to exclude to that text file, and removed the


     line from the batch file.

    This didn't work either....

    LVL 16

    Expert Comment

    the entries in your file exclusion file (awful word play) shoud look like the snippet attached.

    anyway, this


    should be this


    and not this


    Open in new window


    Author Comment

    I definitely appreciate your help.

    But that didn't work either...

    This is why I posted to EE. I've been doing as much reading about it as I could find, and it <i>should</i> work. But it doesn't. I get no error codes or anything.

    Anyway, the exclusion file types in the text file DO work. I've tested that successfully. Using File Size exclusions works, etc.

    Just excluding the directory by path path refuses to work.
    Could it have anything to do with the -avzr switches? I didn't think any of those would prevent a child directory exclusion...

    Thanks again for your help.
    LVL 16

    Accepted Solution

    Don't think so. By the way, -r is useless because -a already includes it (actually, -a is -rlptgoD)
    Have a look at this if it can help you, particularly the comments ( it seems is a bug

    Author Comment


    Yeah, I realized through enough reading of man pages and articles that 'r' was inherent in 'a', I just hadn't taken it out yet as I was mired in this exlusions thing...

    In any event, this worked!

    What was messing me up was this part: "Note: the directory path is relative to the folder you are backing up."

    So since I was backing up the My Docs folder, and the excluded directory was there, all I had to do was add the directory name to the exclude.txt file rsync was reading from.

    So now, all exclusion can live in that one text file, which is pulled newly from the server for each backup. Now allows a lot of control over what we are backing up.

    Great news!

    Thanks again for your help. This really gets me out of a bind.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    How to update Firmware and Bios in Dell Equalogic PS6000 Arrays and Hard Disks firmware update.
    VM backup deduplication is a method of reducing the amount of storage space needed to save VM backups. In most organizations, VMs contain many duplicate copies of data, such as VMs deployed from the same template, VMs with the same OS, or VMs that h…
    To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
    This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now