6

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?

11

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.

3

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

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!

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.