Created
December 16, 2011 17:40
-
-
Save shadowhand/1487069 to your computer and use it in GitHub Desktop.
MySQL Server Migation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$host = 'remotehost.com'; | |
$servers = array( | |
'db/username' => 'password', | |
); | |
foreach ($servers as $db => $pw) | |
{ | |
$command = strtr('mysqldump -u:db -p:pw :db | ssh :sv "mysql -u:db -p:pw :db"', array( | |
':sv' => escapeshellarg($host), | |
':db' => escapeshellarg($db), | |
':pw' => escapeshellarg($pw), | |
)); | |
shell_exec($command); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This works best when your server is set up to login using pubkeys, so that you don't have to type your password for every database.