Created
February 2, 2010 22:26
-
-
Save tkaemming/293110 to your computer and use it in GitHub Desktop.
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 | |
// You'll want to change this to reflect the proper include path. | |
// I just put it in dump/ or a directory like that. | |
require_once '../wp-config.php'; | |
$filename = sprintf('dump-%s.sql', time()); | |
$file = fopen($filename, 'a'); | |
$command = sprintf('mysqldump %s -h %s -u %s --password=%s', DB_NAME, DB_HOST, DB_USER, DB_PASSWORD); | |
$descriptorspec = array( | |
0 => array("pipe", "r"), // stdin | |
1 => $file, // stdout | |
2 => array("pipe", "w") // stderr | |
); | |
$process = proc_open($command, $descriptorspec, $pipes); | |
if (is_resource($process)) : | |
echo '<h1>Results</h1>'; | |
echo '<h2>STDOUT:</h2>'; | |
echo sprintf('<p>Dumped to "%s".</p>', $filename); | |
echo '<h2>STDERR:</h2>'; | |
echo stream_get_contents($pipes[2]); | |
else: | |
die("Failed to dump."); | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment