I have the following settings in my configuration file: (/etc/rsnapshot.conf)
Script/Tool: http://www.rsnapshot.org/
backup_script ssh [email protected] "sh /home/user/backup_mysql.sh" ./mysql
the example shows the following:
backup_script ssh [email protected] "mysqldump -A > /var/db/dump/mysql.sql" unused2
The error I get:
ERROR: backup_script /usr/bin/ssh returned 255
What am I doing wrong?
rsnapshot configuration files are tab delimited. Make sure you include
tabs
between the backup_scrip, the ssh command, and the backup storage. If that does not work try runningrsnapshot configtest
to identify the problem.Answer updated
It is more convenient to transform your backup line to the following format:
Place the middle section in a shell script, make it executable and test it. In addition to this, the
ssh [email protected]
should connect to the remote host without a password non-interactively.The
rsnapshot.conf
example actually usesbackup_exec
, notbackup_script
. However,backup_script
can still be used to run arbitrary commands over ssh and sync any files generated in a temp directory. Any commands used must be referenced by absolute path. This worked for me, for one of my mysql databases:backup_script [tab] /usr/bin/ssh [email protected] "/usr/bin/mysqldump --single-transaction -u username dbname" > dbname.sql [tab] example.com/mysql/
One possible way would be converting
ssh [email protected] "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.
The problem is something to do with ssh. From the ssh man page
You should use ssh -v[vv] to get a verbose output from ssh and see what it has to say.
Have you set up key authentication with the remote host, or is the ssh command expecting you to type in a password interactively?
If you haven't set up passwordless authentication, then the ssh command will fail to authenticate, and hence return an error (255 seems to be the default return value for any error).
I had a similar issue that was solved by making sure that there weren't tabs in the script "path".
Instead of
try