Skip to content
Snippets Groups Projects
Verified Commit a9119246 authored by Fabian Raab's avatar Fabian Raab
Browse files

Create path hirarchy of source path automatically in destination

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.

This Merge Request adds a little script which creates the required
directories in the destination before running rsync. It assumes that
the base-directory already exists, so that not too much directories
are created automatically (could be a mess if you accidentally type the
wrong path)
parent f9529d1d
No related tags found
No related merge requests found
......@@ -749,6 +749,30 @@ function prepare_storage {
section="`basename $SECTION`"
# create $SECTION directories, but not $backupdir
if [ "$dest" == "local" ]; then
if [ -d "$backupdir" ]; then
mkdir --parents $backupdir/$SECTION
else
fatal "The destination $backupdir does not exist"
exit 1
fi
else
(
$ssh_cmd <<EOF
##### BEGIN REMOTE SCRIPT #####
if [ -d "$backupdir" ]; then
mkdir --parents $backupdir/$SECTION
else
echo "FATAL: The destination $backupdir does not exist"
exit 1
fi
##### END REMOTE SCRIPT #######
EOF
) | (while read a; do passthru $a; done)
fi
if [ "$format" == "short" ]; then
suffix="$section.0"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment