<div dir="ltr"><div><br></div><div>I've been using rsync for years to backup my machines both at work and at home.</div><div>These days I faced a new "challenge": at work I connect my laptop to a docking station with an external usb disk. I'd like to use this disk as a backup volume.</div><div><br></div><div>I put my disk in /etc/fstab to be mounted at boot (with 'nofail' option to avoid errors when I'm at home). I have no problems if the laptop is booted after the connection to the docking station but, if I work at home, suspend the laptop and then go to work and connect it to the docking station and resume it, the /backup volume will not be mounted automatically.</div><div><br></div><div>I found that rsyncd.conf can execute scripts before and I tried to create a script to be executed (as early stage or pre transfer? a bit confuser about it) to check if /backup is mounted and mount it if not.</div><div><br></div><div>I verified that the script is executed (I put there some debugging "echo" sent to the log file) but the mount command within it does not mount anything.</div><div><br></div><div>Here it is the rsyncd.conf</div><div><br></div><div><div>##################################</div>read only = false<br>write only = false<br>usechroot = true<br>uid = 0<br>gid = 0<br><br>early exec = /tmp/test-pre-exec<br><br>[rsync-backup-xxx]<br>        comment Local rsync-backup of xxx<br>        path = /backup/xxx<br>        log file = /var/log/rsyncd.log</div><div>##################################</div><div><br></div><div>and the script /tmp/test-pre-exec</div><div><div><br></div><div>##################################</div><div>#!/bin/sh<br><br>echo -n "executing pre-xfer script ..." >> /var/log/rsyncd.log<br><br>if ! grep -qs '/backup ' /proc/mounts<br>then<br>    echo -n "mounting /backup ..." >> /var/log/rsyncd.log<br>    /usr/bin/mount >> /var/log/rsyncd.log<br>fi<br><br>echo " done" >> /var/log/rsyncd.log<br><br>exit 0</div><div><div>##################################</div><div><br></div></div></div></div>