You could amend this script for your specific purpose.
Or install syncthing from the repo (website https://syncthing.net/)