Workaround for rsnapshot bug – space in directory name


rsnapshot is my go-to backup tool for Linux servers that have simple backup requirements.

I use rsnapsnot because:

  • It’s simple to install and configure
  • It’s space-efficient, by taking advantage of hard links.
  • It re-uses existing, widely deployed, and often used Unix tools: SSH, and rsync
  • Backups can be easily accessed; each backup snapshot exists in a separate directory

rsnapshot is not without its considerable flaws (see the bug below), but currently it best meets my requirements.


The last released version of rsnapshot contains a bug which causes issues if your backup point (location you’re backing up) or snapshot root (location you’re backing up to) contains a space in its full path.

From the official rsnapshot FAQ

Q: I have a snapshot root or backup point with a space (or other special character) in it and this is not working at all with rsnapshot 1.3.1. Why?

A: rsnapshot version 1.3.1 has an issue where the rsync command is interpreted by a shell rather than directly executed by rsnapshot. This bug is expected to be fixed in rsnapshot CVS on 24 March 2009, and so should appear an a forth-coming release (probably version 1.3.2). This bug was not present in rsnapshot 1.3.0.

Triggering the bug will print an error message similar to this:

rsync: link_stat "/home/bob/test/My" failed: No such file or directory (2)
rsync: link_stat "/var/cache/rsnapshot/Docs" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1070) [sender=3.0.9]

Unfortunately, rsnapshot development has ceased, so the issue may never be fixed.


Note: This solution fixes the case where the backup point (location you’re backing up) contains a space. This solution has not been tested with a snapshot root (location you’re backing up to) that contains a space. This should not be a big issue, as you probably have complete control of the location of the snapshot root, whereas that may not be the case for the backup point.

The solution is to create a symlink (which contains no spaces in its full path) to your affected backup point (i.e. the one that contains spaces).

For example, given that you want to backup “My Docs”, that has the following full path:

/home/bob/My Docs

Create a symlink to circumnavigate the “My Docs” directory:

ln -s /home/bob/My\ Docs /home/bob/My_Docs

rsync when used with its usual flags (specifically archive mode) will ensure that symbolic links are preserved in transfers; To copy the files that the symlinks point to, you can leverage rsync’s –copy-links flag (see the man page). rsnapshot can then be configured to pass this flag to the underlying rsync command (remember to tab-separate the fields):

backup /home/bob/My_Docs localhost/My_Docs rsync_long_args=--copy-links

Final point

The solution doesn’t completely preserve structure of the backup point (as symlinks are turned into real files) — so if you need the file structure preserved for the backup to be considered complete/correct, then this solution is not correct. This solution however ensures that you will not lose any file data.