Last Updated on
This is just kind of for fun – I recently had a situation where a random directory needed to be transferred between servers on a daily basis. This actually has a business use, but you might have to get creative to see where it would be useful. I did this with an SSHFS mount – which is more less a temporary solution until a proper mount point is configured over NFS or Samba etc. In this case the source dir from which a random directory is selected is
and the SSHFS target mount is
Rsync takes care of the rest, It’s very simple:
PATH=/yourpath ##for chron runs
sshfs -o reconnect -p 11007 root@localhost:/ /mount/landing
hash=$(ls /mount/master/source/ | shuf -n 1 ) ##picks a random dir
echo 1. "$hash"
rsync -raz "/mount/master/source/$hash" "/mount/landing/" --progress
Alternative ports for SSH and reverse tunneling – this is the reason for the non-standard port used above.