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
1 | /mount/master/source/ |
and the SSHFS target mount is
1 | /mount/landing/ |
Rsync takes care of the rest, It’s very simple:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #!/bin/bash env PATH=/yourpath ##for chron runs export path sshfs -o reconnect -p 11007 root@localhost:/ /mount/landing clear 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.
Great content! Super high-quality! Keep it up! 🙂