Last active
June 21, 2016 20:11
-
-
Save ultimagriever/7754aa911c336660cfc18bf6375eb172 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 | |
// php -f export-aws-s3-wordpress.php <host> <db> <user> <password> <url> <bucket> [ --dry-run] | |
array_shift($argv); | |
list($host, $db, $user, $pass, $url, $bucket, $dryrun) = $argv; | |
$cmd = 'wp search-replace "' . $url . '/wp-content/uploads" "' . $bucket . '/wp-content/uploads" --url=' . $url . ' --network ' . $dryrun; | |
echo $cmd . PHP_EOL; | |
echo shell_exec($cmd) . PHP_EOL; | |
$con = new PDO('mysql:host=' . $host . ';dbname=' . $db, $user, $pass); | |
$rs = $con->query("SELECT blog_id, path FROM wp_blogs WHERE path <> '/'"); | |
$blogs = $rs->fetchAll(PDO::FETCH_NUM); | |
foreach ($blogs as $blog) { | |
list($id, $path) = $blog; | |
$cmd = 'wp search-replace "' . $url . '/wp-content/blogs.dir/' . $id . '/files/" "' . $bucket . '/wp-content/blogs.dir/' . $id . '/files/" "wp_' . $id . '_*" --network --url=' . $url . ' ' . $dryrun; | |
echo $cmd . PHP_EOL; | |
echo shell_exec($cmd); | |
echo PHP_EOL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment