Handle big/automated WXR exports with the WordPress CLI Exporter

If you run a big site or many blogs and would like to create some automated exports or run into memory/runtime issues with the web based exporter then this wrapper around the existing web-based WordPress exporter will likely help you out here.

Grab the file from https://github.com/tott/WordPress-CLI-Exporter and copy it to your WordPress root folder or any other convenient location.

Make sure to set $wordpress_root_dir and $_SERVER['HTTP_HOST'] according to your environment.

Then execute the script with the following parameters ( brackets indicate optional parameters ):

php cli-exporter.php --blog=blogname --path=/tmp/ --user=admin [--start_date=2011-01-01] [--end_date=2011-12-31] [--post_type=post] [--author=admin] [--category=Uncategorized] [--post_status=publish] [--skip_comments=1]
  • blogname: the name or blog_id of the blog you like to export
  • path: the full path to the directory where exports should be stored
  • user: the WordPress username that will run this export
  • start_date: only export posts older than this date (format: YYYY-MM-DD)
  • end_date: only export posts newer than this date (format: YYYY-MM-DD)
  • post_type: export only posts matching this post_type
  • author: export only posts for this user_login or user_id
  • category: export only posts with this category name
  • post_status: export only posts with a particular post status
  • skip_comments: if this is set to 1 then comments will not be exported

I hope this is useful.

5 Responses to “Handle big/automated WXR exports with the WordPress CLI Exporter”

  1. I think you meant https://github.com/tott/WordPress-CLI-Exporter instead of https://github.com/tott/WordPress-CLI-Importer but both will be very valuable.

    Much thanks!

    Jan Dembowski

  2. This would be great except it’s only for WordPress MU. Errors on the function call get_blogaddress_by_name() when run on WordPress (single blog).

  3. New pull request 🙂 Happy to help you maintain the repo if you’d like.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: