I am on Ubuntu 20.04 and I use the bash script / rsync below to connect to rsync-daemon on my remote server over ssh.
The downside is that using rsync over ssh also creates server load, therefore as to overcome the problem of server load, I added an ionice value as shown below. Load is no longer a problem.
My issue is that the ionice value seem to cause an unstable ssh connection and that in turn causes my login-notifier script to send a million emails because ssh keeps dropping and re-connecting continuously.
Might someone see a better solution to the load problem and/or know how to keep the ssh connection stable?
#!/bin/bash
while [ 1 ]
do
rsync -avzxP --delete --checksum --append-verify --timeout=180 --bwlimit=48 --rsync-path="sudo ionice -c 3 rsync" --log-file=/var/log/rsync.log --exclude 'var-logs' --password-file=/etc/rsyncd.passwd -e "ssh -l backups" XXX.XX.XXX.XX::backup-data /media/username/WebMade/Server-Backups/Prod/today/
if [ "$?" = "0" ] ; then
echo "rsync completed normally"
exit
else
echo "Rsync failure. Backing off and retrying..."
sleep 10
fi
done
#EOF
[ 1 ]checks if1is a non-empty string.[ 0 ]checks if0is a non-empty string. Each returns success. This means1you used has no connection to the logic of the script; it only looks relevant if you don't know how[works.true(not[ true ]) makes more sense here, asfalse(unlike[ 0 ]or[ false ]) would really disable the loop.:is a no-op that returns success, it's the simplest what you can use here (and I don't mean[ : ], I mean sole:in place of this[ 1 ]of yours).nicein the code, I seeionice.