ryclem Posted March 9, 2009 Share Posted March 9, 2009 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 More sharing options...
Maq Posted March 9, 2009 Share Posted March 9, 2009 I always use shell_exec() and never have a problem. How are you running this script? Link to comment https://forums.phpfreaks.com/topic/148548-mysqldump-to-another-server-using-ssh/#findComment-780099 Share on other sites More sharing options...
ryclem Posted March 9, 2009 Author Share Posted March 9, 2009 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? Link to comment https://forums.phpfreaks.com/topic/148548-mysqldump-to-another-server-using-ssh/#findComment-780295 Share on other sites More sharing options...
fenway Posted March 13, 2009 Share Posted March 13, 2009 What's "not working" about it? Link to comment https://forums.phpfreaks.com/topic/148548-mysqldump-to-another-server-using-ssh/#findComment-783830 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.