rsync: allow to backup non-root directories
Before it was only possible to backup root directories (depth one, eg. /etc, /var, /usr, …). For example consider the following truncated toy configuration for rsync:
[general]
mountpoint = /media/
backupdir = backup
[source]
include = /foo/bar
include = /etc
We assume you have prepared the existent but empty base-directory /media/backup/ at your destination, then against the expectation, the following error rises:
rsync: mkdir "/media/backup/foo/bar/" failed: No such file or directory (2)
The reason is that rsync will take the files from the folder /foo/bar/ and tries to put them into the ulitmate – and therefore existent – destination /media/backup/foo/bar. This is not what you would expect, since the prepared directory /media/backup exists and the application should create the rest itself.
But rsync has a feature for that, wich does exactly what we want,
called --recursive
. With this you can define a base-directory, under
which directories are created when necessary.
This commit adds this option and defines the
$mountpoint/$backupdir
(here /media/backup folder as base-directory).
Then all subfolders would be automatically created by rsync and the
above error would dissapear.
This change is fully backwards compatible and does not deprecate any configuration or syntax. Existing includes in configuration do backup at the same destination directory as before.