How to exclude directories with certain names from rsync on Linux?

How to exclude directories with certain names like “cache” from rsync on Linux during backup?

The “cache” directory may in many different paths, such as file1/cache/ or file2/cache/, and adding all “cache” directories to rsync command is not a doable way.

You can use rsync with --exclude=cache/ like

rsync -avxP --exclude=cache/ /path/to/src/directory/ /path/to/dst/dir/

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *