I have created a bash script as follows and saved it as
#!/bin/bash rsync -ar --delete /files/database_backups firstname.lastname@example.org:/users/slyme/Documents/server_backups
I have generated the necessary pair of authentication keys to make this work without the need to enter a password.
When I run the command directly it works (hurrah!).
I have added the following to `/etc/rc.local':
/usr/bin/db.sync.sh >>/files/database_backups/db-sync.log.txt 2>&1
When I restart the machine this script fails and the log file suggests that the process asks for a password which, of course, it doesn't get so it fails. If I run
/etc/rc.local from the command line then, sure enough, I get asked for a password and when I enter it the script works.
Anyone got any ideas why the script needs a password when run from rc.local even though it doesn't need a password when run directly?