I'm using SCP to backup files from my VPS in the cloud to my PC. In an early version of the backup script there is one single SCP command to backup everything from the server root. This works flawlessly..
However, as the server grows, this is starting to get big so I'm changing the script to run SCP commands on specific directories (about a dozen). And now some of the individual SCP commands fail at random with "connections refused". But the next SCP command in the script works... I have added a 5-second delay between each SCP command in case there is some throttling somewhere but this is not enough.
What can be causing this? What can I check?
netstat on the server after the script has run shows several ssh connections from my IP (including of course the connections to issue
netstat but this would only be one o f them?).
In case it matters the server is running Ubuntu Server 16.04 and my PC runs Ubuntu 14.04.