2 min read

How to include and exclude files and folders from BackupPC using rsync

How to include and exclude files and folders from BackupPC using rsync. How to backup certain folders and exclude anothers using BackupPC.

I'm leaving this here as documentation for my future self. Recently I added a second backup server for some redundancy, but I didn't want to backup everything twice, just some folders.

Well, turns out this was harder then expected, because the BackupPC documentation was not quite clear (at least to me).

To include files, we should use the BackupFilesOnly setting, and to exclude them the BackupFilesExclude. They're both located on the Xfer tab, in Edit Config for the host you're backing up.

The confusing bits for me were when to use the ShareName, when to use the Insert or Add option, if the folders were expecting a trailing slash or not, if this worked with wildcards or not, and so on.

So, what I wanted to do was to backup some folders on my /home, while excluding larger folders nested there.

So, long story short, we need the following settings for this:

  • RsyncShareName
  • BackupFilesOnly
  • BackupFilesExclude

The RsyncShareName should be set to your home, like /home/diogo. On the BackupFilesOnly we should again Add the New ShareName or '*' as /home/diogo and then, inside that, Add the folders we want to backup, such as /docker. So, if the only folder you want to backup is /home/diogo/docker, then you have to do all these steps exactly.

If you want to backup more folders just Add them one by one "inside" that share name.

Now to exclude some folders inside that docker folder. On the BackupFilesExclude you need to Add, again, the New ShareName or '*' as /home/diogo, and then inside it Add the folder(s) we want to exclude. I want to exclude a folder named data nested inside the docker folder, so I should write it as /docker/*/data. This combination of settings will backup everything inside the /home/diogo/docker/*/*, except the folders named data. Don't forget to hit Save on the top left corner!

If this looks a bit confusing, it's because it is! So I'll leave an image that should make things more clear.

I hope this will be helpful to someone else. I saw several similar questions online but not a clear answer, which is now here. 😃