Specifying remote directories to be excluded from rsnapshot backup
Solution 1
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
.
Solution 2
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
Solution 3
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!
Related videos on Youtube
Tom Russell
Middle-aged software developer trying to stay on top of latest trends in web application technologies. My current passion is single-page apps using Polymer web components to connect with REST APIs. I love science and science fiction. I've been around long enough to see some of the visions of science fiction authors come to pass. Remember the old "Danny Dunn" books? In one of them, Danny created a mosquito-sized drone that could fly around and invade all kinds of privacy. This was back in the 1970s! Fascinating and potentially disruptive as robotics, computing and internet technologies are, my true love will always be the hard sciences.
Updated on September 18, 2022Comments
-
Tom Russell almost 2 years
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). Thebackup
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 oftom@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 thelocalhost
andlaptop
backups, and causes my PID to flare up.My solution for now is to simply have separate
rsnapshot
config files for each host, and executersnapshot
once for each host. But this shouldn't be necessary.So how would I exclude a directory from only the remote (laptop) backup?
-
Steve Almond almost 5 yearsTo whoever edited this answer to say "pluses are a good idea": adding a plus causes configtest to fail. Your edit edited accordingly.
-
Tom Russell over 4 yearsIt 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?
-
Tom Russell over 4 yearsThanks. 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.
-
MaXi32 almost 4 yearsit's comma, and the output will show u exclude=