Put full path to rsync even to your /usr/bin/backup, so the line in that file would start
/usr/bin/rsync <your other options>
And try to put a line like
logger -t my_backup Hello from /usr/bin/backup
to your /usr/bin/backup script and see if anything gets logged to /var/log/messages (or other log file, depending on your syslog setup). Alternatively you might replace the logger with
echo "Hello from /usr/bin/backup" >/tmp/backuptest
Oh, sometimes SELinux might cause problems like you have encountered. Is it in use?
Hope this helps.
EDIT: Make your /usr/bin/backup rsync line be like
/usr/bin/rsync <your options> || echo "rsync died with error code $?" >> your_log
Perhaps we'll catch why rsync is so upset.
YET ANOTHER EDIT: OK, rsync error code 5. That means
rsync error: error starting client-server protocol
Most of the time that happens due the wrong password, even though the message looks more cryptic.
If you manually run your rsync script as niklas, that works, right?
EDIT 3: Spotted your mention about keyring. I think cron doesn't use the same keyring than the user niklas during your login. That's why the login goes p00f when trying to run it from cron. Could you use a passwordless RSA key for this instead and just restrict it to run rsync?
EDIT 4: Use RSYNC_PASSWORD environment variable. That can be done by putting this to top of your backup script:
export RSYNC_PASSWORD="myprecioussssssss"
or if you would like to store the password in a textfile, create a file and provide a --password-file option to rsync.
If that doesn't work, you may provide -e 'ssh -o IdentityFile=/path/to/your_file option to rsync.
Best Answer
One possible way would be converting
ssh root@host.domain.com "sh /home/user/backup_mysql.sh"
into a script (do_ssh.sh,here) and invoke that script.Something like,
I'd also recommend you to try putting quotes around your entire command.