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.
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.
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.
export
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
import
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.