Exclude folder from rsync backup

Written by
Date: 2012-02-08 10:50:00 00:00

You may have already know how to do this, but just in case, I'll put here this small tip.

If you want to backup using rsync, or just transfer some files from one server to another, being them Unix, Linux DSD or Apple's OSX, you can do it using rsync.

What I like about this tool, besides it keeps incremental backups, is that you can easily exclude some folders from the backup.

Let's say you have this folder structure.

  • /home/user/documents
  • /home/user/pictures
  • /home/user/movies
  • /home/user/backup

Now suppose you want to copy them to your laptop, but you do not need the movies.

rsync -av --delete --exclude movies user@desktop:/home/user/ /home/user/

Execute the command from the laptop, and it will copy all files from desktop to laptop, but the folder movies and its content.