How To Export WordPress From The Command Line CLI

Create a file called export.php in the wordpress top directory containing the following (remember to add the PHP tags at the top and bottom):
1 2 3 4 5 6 7 8 9 10 11 |
include 'wp-config.php'; include 'wp-admin/includes/export.php'; ob_start(); export_wp(); $file = ob_get_contents(); ob_end_clean(); $fh = fopen("wordpress-" . date('Y-m-d') . ".xml", 'w'); fwrite($fh, $file); fclose($fh); |
You are on the right track here but I’m pretty sure this will only work for a single blog. I need multisite support but I’m used to dealing with issues like this. Your approach has put me on the right track, so thanks!