11

I've looked around a bit without finding an exact answer to my question, which is how to specify a directory to be excluded from only the remote filesystem backup.

Say I've got two machines: a desktop (server) and a laptop. My home directory on each of them is /home/tom. rsnapshot lives on the desktop (localhost) with its config file(s). The backup commands, therefore, are:

backup /home/tom/ localhost/
backup tom@laptop:/home/tom/ laptop/

All well and good. But say I've got /home/tom/music on the laptop. It's stuff copied over from the desktop, and large. But when I go to exclude /home/tom/music/ from only the backup of tom@laptop:

exclude tom@laptop:/home/tom/music/

But this doesn't result in music/ being excluded, and causes my herpes to flare up.

Doing this:

exclude /home/tom/music/

of course causes music/ to be excluded from both the localhost and laptop backups, and causes my PID to flare up.

My solution for now is to simply have separate rsnapshot config files for each host, and execute rsnapshot once for each host. But this shouldn't be necessary.

So how would I exclude a directory from only the remote (laptop) backup?

3 Answers 3

17

There is a fourth field for the backup line, which can be used for such tasks. So your line should look like follows.

backup tom@laptop:/home/tom/ laptop/ exclude=/home/tom/music

You can add more per backup options by separating these with a comma. For further reading consult the man page of rsnapshot.

2
  • It might be helpful to know the syntax for adding other excluded directories. Are they comma-separated, or is the "exclude=..." phrase simply repeated with each value? Feb 22, 2020 at 1:49
  • 1
    it's comma, and the output will show u exclude=
    – MaXi32
    Jul 25, 2020 at 15:59
8

Since this is the top result for my google search, I think the following might help others too:

Thomas' command works, but it removes all globally defined exclude directives in /etc/rsnapshot.conf

In order to keep existing excludes you can use the following

backup tom@laptop:/home/tom/ laptop/ +rsync_long_args=--exclude=/home/tom/music
1
  • 1
    Thanks. I believe this effect reared its ugly head causing me to abort my attempt to use a single rsnapshot config. Maybe now I'll try doing it right. Feb 22, 2020 at 1:53
1

Note the equals sign in Thomas' example. If you miss it, rsnapshot configtest fails with an error suggesting you use tabs!

You also don't need to prefix the exclude= with a plus, as some other Q&As suggest -- and if you do, rsnapshot configtest will fail with 'uninitialized value in concatenation or string'.

Here's an example with multiple excludes:

[..]
exclude    /foo1
exclude    /foo2
[..]
backup    /from    /to    exclude=/bar,exclude=/baz

Note also that excludes starting with slash are relative to the backup root (i.e., relative to $snapshot_root/from) and NOT relative to the server root. That's surprised a lot of posters!

1
  • To whoever edited this answer to say "pluses are a good idea": adding a plus causes configtest to fail. Your edit edited accordingly. Aug 8, 2019 at 9:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .