rsync with mode --delete

Budi Janto budijanto at
Sat Jun 27 07:21:58 UTC 2020

On 6/27/20 5:01 AM, Wayne Davison wrote:
> There are several options:
>  1. Set the "pre-xfer exec = /script/name" in your daemon module and
>     make the script check if a /mnt/DATA/known-to-exist-subdir is
>     missing and if so, do an "exit 1".
>  2. If your server rsync is at least 3.2.1, set the "early exec =
>     /script/name" in your daemon module and make the script verify that
>     the drive is mounted & attempt to mount it if it is not (return an
>     error code if unable to mount it).  The mount action is not possible
>     in the pre-xfer exec script because rsync has already done a chdir
>     to the empty mount by the time this script runs.
>  3. Move everything down into a deeper directory and tweak the path in
>     your daemon module to be "path = /mnt/DATA/subdir" so that the
>     transfer will fail when the mount is not there (because the subdir
>     is not there).
For a moment, I use validation to make sure server side -NOT- empty
directory. For example:


TEST="$(rsync -n rsync:/ | awk 'END {print NR}')"

if [ "$TEST" -gt "1" ]; then
    rsync -avPH --delete rsync:/ /mnt/DATA/
    exit 0

Probably, your suggestion (option 1) is more handy to applied. Thank you.


Budi Janto

More information about the rsync mailing list