Jump to content

mysqldump to another server using ssh


ryclem

Recommended Posts

I have a problem that is frustrating the crap out of me…. I’m trying to do a mysqldump to another server (obviously don’t want to keep the backup on the same server)…. I’m trying to do this through PHP like the following:

 

$remote_backup = “/usr/bin/mysqldump $dbname –opt -h$host -u$user -p$password | gzip -c | ssh [email protected] ‘cat > /home/httpd/vhosts/domain.com/backups/2009-03-07-15-13-56.gz’”;

system($remote_backup);

 

This not working from PHP, however when I run it direct from SSH shell below it works perfectly.

 

/usr/bin/mysqldump $dbname –opt -h$host -u$user -p$password | gzip -c | ssh [email protected] ‘cat > /home/httpd/vhosts/domain.com/backups/2009-03-07-15-13-56.gz’

 

I setup key authentication so that SSH does not prompt for a password, but it is still not working from PHP.

 

What am I doing wrong? I’ve spend tons of time searching for this solution…. any help would be greatly appreciated.

 

Thanks,

Ryan

Link to comment
https://forums.phpfreaks.com/topic/148548-mysqldump-to-another-server-using-ssh/
Share on other sites

Currently, I am attempting to do it with system

 

$remote_backup = “/usr/bin/mysqldump $dbname –opt -h$host -u$user -p$password | gzip -c | ssh [email protected] ‘cat > /home/httpd/vhosts/domain.com/backups/2009-03-07-15-13-56.gz’”;

system($remote_backup);

 

However, I just tried it with the following:

$output = shell_exec('$remote_backup');

echo "<pre>$output</pre>";

 

this still isn't working for me... I also tried it with just shell_exec('$remote_backup'); and that didn't work either.  Any additional thoughts?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.