Exclude a list of files with rsync

  • Written by Dave on Friday 3 February 2012

Most of you will be familiar with rsync - a nice little *nix tool that syncs files between a given source and destination. Its original purpose was to allow an easy way of creating backups from a multitude of *nix clients to a single server.

Depending on your workspace you might want to always skip a series of source files before sending them over. You can do this easily with the --exclude-from=/path/to/exclude/folder parameter.

In my dotfiles I made an alias for rsync that incorporates this param, so every sync I execute will only push the files I want it to.

alias rsync='rsync --exclude-from=$HOME/.bin/rsync-exclude-list.txt'

Example of an rsync-exclude-list.txt:

.svn/ 
files/ 
cache/ 
install/ 
.DS_Store 
Thumbs.db

So every time I use rsync, it would effectively ignore all matches in the file above. You can still use any parameters freely:

rsync -vurn www/ davelens.be:www/

About this b(ack)log

You can skim through the archive or subscribe to the RSS feed if you'd like to read more. Also, you can find me on GitHub.

If you have questions or remarks, or you want to say hi, you can drop me a line.