Is it possible to export WordPress from command line?

I don't mean use mysqldump to export the database, but create the xml file used to easily import to another WordPress installation.

2 Answers 2


Check out http://wp-cli.org/. It's fantastic and I've used the export capability multiple times.

More information on wp-cli.

WP-CLI is a set of command-line tools for managing WordPress installations. You can update plugins, set up multisite installs and much more, without using a web browser.

You will most likely have to install wp-cli. You can find instructions on wp-cli.org. There are also alternative installation instructions here: https://github.com/wp-cli/wp-cli/wiki/Alternative-Install-Methods

To export your posts using wp-cli, you can use the command.

wp export

There are many options to limit the export by date, post type, category, author, etc. Most details can be found on this page: http://wp-cli.org/commands/export/

I don't know of any other way to export an xml file from the command line.

  • Don't post only links as answers. Please add a short description/explanation from the link and use he link as to credit the person/site where the info came from. This is just to ensure that if that link dies due to the website going down or gets removed, your answer will still be useful without the link May 21, 2014 at 19:37
  • 1
    Hi @AdamH, it looks like you are new to StackExchange. While this site is a great resource, the community tends to be rather picky about what makes an acceptable answer. Providing only a link is something that is generally better for a comment, as an answer needs to actually answer the question. Of course, you'll have to earn some points before you can leave a comment.
    – Paul
    May 21, 2014 at 19:37
  • I've updated my answer with a little more information about wp-cli and how to use the specific feature @Paul was looking for.
    – Adam H
    May 21, 2014 at 19:47
  • Thanks for the update. This is what keeps the site constructive. +1 May 21, 2014 at 19:47


wp export --dir=/var/www/site.com/htdocs/backup --user=admin --post_type=post --start_date=2021-05-07 --end_date=2021-05-08 --allow-root


wp import example.wordpress.2021-05-08.000.xml --authors=create --allow-root

If you are not root, discard --allow-root

Change example.wordpress.2021-05-08.000.xml to your filename

You need to change the information according to your usage. Directory name, filename, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.