Jump to content

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 user@111.222.333.444 ‘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 user@111.222.333.444 ‘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 user@111.222.333.444 ‘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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.