Why does rsnapshot not exclude directories I specify?

4.6k Views Asked by At

I am setting up backups with rsnapshot but I'm having trouble with the excludes. I have read a lot about it and I know that there are important differences in rsync regarding the use of slashes. But I don't get why this doesn't work. My (simplified) folder structure inside /path/to/files/my_files/ is something like this:

folder1
folder2
folder3
-- subfolder1
-- subfolder2
folder4

I want to exclude folder1 here. The rsync command in /etc/rsnapshot.conf is something like:

backup  remote_user@remote_server:/path/to/files/my_files/    my_files/

While my exclude file (also defined in /etc/rsnapshot.conf) looks like this:

- /folder1

I also tried - folder1, - /folder1/, and - folder1/. But none of them works the way I want. For example, using - folder1 excludes the folder I want, but also every other folder whose path includes the string folder1. On the other hand, the others don't exclude the folder I want to exclude.

This really drives me crazy, I have read so many examples and it feels like I tried every possible combination - but to no avail. Can anybody tell me what I'm doing wrong? Is there something special about excludes in rsnapshot that makes it different from a simple rsync call? Because there I have no problems.

2

There are 2 best solutions below

1
On BEST ANSWER

rsnapshot invokes rsync with the --relative option. One of the things that this changes is the way include/exclude rules work.

Try this:

- /path/to/files/my_files/folder1
0
On

Another option to exclude a specific folder is to add an exclude "path-pattern" to /etc/rsnapshot.conf file:

# The include and exclude parameters, if enabled, simply get passed directly
# to rsync. If you have multiple include/exclude patterns, put each one on a
# separate line. Please look up the --include and --exclude options in the
# rsync man page for more details on how to specify file name patterns.
#
exclude         ".cache/"
exclude         "/path/to/your/folder"