How can I exclude files by default with rsync? Here is how my normal rsync syntax starts out:

rsync --exclude ".ht*" --exclude "error_log" --exclude ".DS*" --exclude "old" ...

I've seen a lot of mention of configuring the /etc/rsyncd.conf file, but maybe that's more for the daemon than the rsync command.

Is it possible to have some default excludes for rsync when called from the command line like in my default syntax above?

4 Answers 4


Add your excludes to a file, then use --exclude-from=/path/to/exclude_file


# cat rsync.excludes

# rsync --exclude-from=rsync.excludes
  • 3
    looks like the syntax is --exclude-from and not --exclude-file but otherwise this seems to be the ticket. thanks!
    – cwd
    Sep 29, 2011 at 15:12
  • the only advantage this gives over @scottatron later answer: this gets more verbose and so much less hidden... but, then again, who gets to this point of rsync needs without a customized shell?
    – cregox
    Aug 30, 2022 at 20:26

No, rsync does not have a default configuration file that it will read upon invocation. The best you can do is what @frogstarr78 says and create a text file with patterns, file and directory names to exclude, and then point rsync to it with --exclude-from=filename.

  • 4
    rsync does not have a default configuration file - that's disappointing
    – cwd
    Sep 29, 2011 at 15:06

While rsync doesn't let you set default options, you can create a wrapper script and put it higher up in your $PATH than the rsync binary.

This is is my rsync wrapper which lives in ~/bin/rsync


# Set path to the rsync binary

# Look for these exclude files
IGNORE_FILES=(~/.rsyncignore ./.gitignore ./.rsyncignore)

for f in ${IGNORE_FILES[@]}; do
  if [[ -e $f ]]; then
    EXCLUDE_FROM="$EXCLUDE_FROM --exclude-from=$f "

It'll look for ~/.rsyncignore, ./.gitignore, ./.rsyncignore files and, if any of them exist, use them as default --exclude-from arguments.

Just change the RSYNC and IGNORE_FILES to suit your envrionment and preferences.

  • much better general solution than current accepted answer, thanks for sharing!
    – cregox
    Aug 30, 2022 at 20:24

--exclude "/*" will exclude everything by default. Here is an example:

rsync -av --include "bin/" --exclude "/*" /source_dir/ /dest_dir/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.