Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm not sure if the heading is really coorect. I have a line in my rsnapshot.conf

backup  root@      srv01/

So rsnapshot creates a directors RSNAPSHOT_ROOT/daily.0/srv01/mnt/rsnapshot and puts the backed-up files there. For me, the /mnt/rsnapshot part is unnecessary; I'd rather have my backed-up files directly in RSNAPSHOT_ROOT/daily.0/srv01/. Is there any way to achieve this?

share|improve this question
up vote 6 down vote accepted

rsnapshot uses the --relative flag of rsync to preserve pathname information. In most cases, you probably do want to keep (at least some of) that information, especially when backing up local directories. However, in your case, you really don't need to keep the leading path prefix.

With reasonably recent versions of rsync (v.2.6.7+), you can explicitly control the portion of the pathname prefix that --relative saves by inserting a ./ at the desired cut-point. The ./ does not effectively change the pathname, but it does tell rsync that you want --relative to only keep the part of the pathname that follows the ./. Since you want to cut off the entire pathname, you simply append the ./ onto the end of the source path, like this:

backup  root@  srv01/


Okay, so it looks like the ./ trick won't work in this case, since rsnapshot strips off the trailing /. Instead, you should be able to disable the --relative option on a per-backup-point basis, by adding a fourth column to your backup line, like this:

backup  root@  srv01/  +rsync_long_args=--no-relative

The +rsync_long_args tells rsnapshot to append to its existing rsync_long_args option, for the current backup-point only. By appending --no-relative to rsync_long_args, you achieve the desired effect of turning off --relative.

share|improve this answer
in theory, and according to the manpage, this should work, but it doesn't -- I still have the /mnt/rsnapshot in my backups. Any idea what could be wrong? – andreas-h Jan 30 '13 at 11:32
Perhaps rsnapshot "sanitizes" the source pathname before passing it to rsync, stripping off the extra ./. Check the log file /var/log/rsnapshot.log, it should show you exactly what rsync commands it is issuing. – Steven Monday Jan 30 '13 at 14:06
rsnapshot seems to cut off the trailing /, so that it rsync with the path root@ Is there anything I can do without disabling --relative? – andreas-h Jan 30 '13 at 18:22
@andreas-h: Check out the EDIT. I hope this solves it for you. – Steven Monday Jan 31 '13 at 3:04

This behaviour is actually controlled by rsync's --relative flag. Quoting the rsync manual:

-R, --relative

Use relative paths. This means that the full path names specified on the command line are sent to the server rather than just the last parts of the filenames. This is particularly useful when you want to send several different directories at the same time. For example, if you used this command:

rsync -av /foo/bar/baz.c remote:/tmp/

... this would create a file named baz.c in /tmp/ on the remote machine. If instead you used

rsync -avR /foo/bar/baz.c remote:/tmp/

then a file named /tmp/foo/bar/baz.c would be created on the remote machine, preserving its full path. These extra path elements are called "implied directories" (i.e. the "foo" and the "foo/bar" directories in the above example). [...]

So, in your rsnapshot.conf find the line that starts with rsync_long_args. By default, --delete --numeric-ids --relative --delete-excluded should be present. Removing the --relative option, should lead to the desired results.

share|improve this answer

Steven's first suggestion to use ./ does actually work with rsnapshot, you just have to put it twice:

backup  root@  srv01/

Rsnapshot will strip the last slash of, but the first dot works for rsync.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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