Raam Dev » thoughts essays journal notes contact about subscribe rss

Using ‘rsync –exclude-from’ to Exclude Files Containing Spaces

A few months ago I wrote a post about escaping filename or directory spaces for rsync. Well that wasn’t the end of rsync giving me problems with spaces.

When I used the --exclude-from rsync option to specify a list of exclusions, I figured using single or double-quotes around files/directories that contain spaces would be enough to escape them. However, after swashing through hundreds and hundreds of lines from rsync’s output, I discovered the excluded directories were still being synced!

When using --exclude-from, files and directories should not contain any single or double quotes, only a backslash:

/afs/*
/automount/*
/Users/raam/Documents/Virtual\ Machines/*

  1. reagan0

    Thanks. This is good information to know. I suspected that this was the case, but this will save me a decent amount of experimentation.

    Cheers!

  2. dalal

    my rsync cmd is as:
    rsync -[options] —-exclude-from=exclude.file /mnt/xyz/ /home

    so in the exclude.file do I include the path as:
    - /mnt/xyz/abc/some.file or
    - /abc/some.file or
    - abc/some.file

    • Hi Dalal,

      The syntax for rsync is rsync [OPTION]... SRC [SRC]... DEST, so your example command will copy things FROM /mnt/xyz/ TO /home. I just want to make sure that’s what you’re trying to do!

      Regarding excluding: I believe the exclude pattern is in relation to the path you’re copying from. So, I think “abc/some.file” is the correct way to exclude in your example.

      To make sure, you can do a “dry run” of the command to see what will happen by using the “-n” option. This causes rsync to show you what it would do, but it doesn’t actually transfer any files.

      I hope this helps!

Leave a Reply

Subscribe without commenting.

Other posts you may enjoy:

Where in the world is Raam?

Join the Facebook Community

Raam Dev » thoughts essays journal notes contact about subscribe rss

Powered by WordPress and other Open Source Software
Uncopyright by Raam Dev