1

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

5
  • I 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)? Jun 16, 2017 at 21:32
  • Well, neither --exclude /home/foo/bar nor --exclude /home/foo/bar/ are working
    – zar
    Jun 16, 2017 at 22:15
  • What command line are you using, and if applicable what configuration file? Copy-paste them into your question. Jun 16, 2017 at 22:35
  • Ok, 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
    – zar
    Jun 18, 2017 at 19:17
  • Copy-paste the complete configuration file into your question. We can't help you if you hide crucial information. Jun 18, 2017 at 21:18

1 Answer 1

3

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.

You must log in to answer this question.

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