The idea of using crontab to schedule netcat commands on two machines was brought up in this question, but the respondents all rebuked the asker and pivoted to talking about scp
instead.
Assuming I am ok with the implications, how would I go about finding what went wrong with this setup? For testing purposes, I was synchronizing these two jobs at 13:45 local. Both computers are on the same local time zone.
Destination crontab:
45 13 * * * nc -l -p 1234 > /path/to/backup-$(date +%F).tar.bz2
Source crontab:
45 13 * * * /path/to/backup_script.sh
Source backup script:
sleep 5 # to ensure the destination is already listening
tar -cvpj --exclude-vcs /path/to/source/files | nc -N dest 1234
On their own (outside of crontab), the listen command and backup script work. It's my understanding that the destination will not stop listening until it receives EOF. However, it's the listening end that seems to not be listening when it should be. I can start it listening manually and the source's scheduled job will send the file, but I'm unable to get the destination to listen at a specified time.