How to exclude symbolic link in rsync/rsnapshot
Unless you set rsync_short_args
or rsync_long_args
in the configuration file for rsnapshot
, you'll use rsync -a
to perform the copy.
The default action for rsync -a
is to copy a symlink as a symlink, and to ignore the target of the symlink. (Obviously, if the target of the symlink is within your source file tree it will get copied, but that's because of its position not because it's the target of an included symlink.)
If you want to exclude the symlink itself, you just need to reference it in an exclude
line:
exclude /foo/bar
I've not included the leading /home
because that's the root of your source tree and filters are always based on the root of the source.
Related videos on Youtube
![zar](https://i.stack.imgur.com/U0tMN.png?s=256&g=1)
Comments
-
zar almost 2 years
I am using
rsnapshot
to manage my backups. The file/home/foo/bar
is a symbolic link to a folder, and I want to exclude it. The--exclude
option does not work, because if the pattern ends with a/
then it will only match a directory, not a symlink.How could I do this?
The
rsync
man page says:if the pattern ends with a
/
then it will only match a directory, not a regular file, symlink, or device.So what I'm asking is: how can I exclude from
rsnapshot
a symbolic link to a folder?If the link is
/home/foo/bar
, which of the following config lines is the right one?exclude /home/foo/bar/ exclude /home/foo/bar exclude /home/foo/bar** exclude /home/foo/bar***
This is the config file that I'm using now:
config_version 1.2 snapshot_root /media/satellite/rsnapshot/ cmd_cp /bin/cp cmd_rm /bin/rm cmd_rsync /usr/bin/rsync cmd_logger /usr/bin/logger retain hourly 6 retain daily 7 retain weekly 4 verbose 2 loglevel 3 lockfile /var/run/rsnapshot.pid exclude /home/roberto/media/ exclude /home/roberto/media exclude /home/roberto/media** exclude /home/roberto/media*** backup /home/ localhost/ backup /etc/ localhost/ backup /usr/local/ localhost/ backup /var/www/ localhost/
Where
/home/roberto/media
is a symlink to/media
, which is a directory-
Gilles 'SO- stop being evil' about 7 yearsI don't understand the problem. Why would the pattern end with a slash? What's wrong with
--exclude=/bar
(assuming that your source is/home/foo
)? -
zar about 7 yearsWell, neither --exclude /home/foo/bar nor --exclude /home/foo/bar/ are working
-
Gilles 'SO- stop being evil' about 7 yearsWhat command line are you using, and if applicable what configuration file? Copy-paste them into your question.
-
zar about 7 yearsOk, now I have in my configuration file the following lines: exclude /home/roberto/media/ exclude /home/roberto/media exclude /home/roberto/media** exclude /home/roberto/media*** --- One of them is the right one, the directory is not copied anymore
-
Gilles 'SO- stop being evil' about 7 yearsCopy-paste the complete configuration file into your question. We can't help you if you hide crucial information.
-