rsync/ssh/rsnapshot backup -- remote script execution

Solution 1:

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,

backup_script /path/to/do_ssh.sh ./mysql

I'd also recommend you to try putting quotes around your entire command.

backup_script "ssh [email protected] "sh /home/user/backup_mysql.sh"" ./mysql

Solution 2:

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 running rsnapshot configtest to identify the problem.

Answer updated

It is more convenient to transform your backup line to the following format:

 backup_script    /dir/yourscript.sh    backupdirectory/

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.

Solution 3:

The rsnapshot.conf example actually uses backup_exec, not backup_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/