WordPress provides a great mechanism for exporting and importing data simply by using Tools > Export or Import. However when used on large datasets, you’re bound to run into timeout issues, especially when that data includes images since it takes time for the importer to grab those images from their source and download them into the destination site.
While most hosting providers (including us on Titanium plans) allow you to adjust the PHP timeout values to increase them to your liking, there are additional timeouts that are not adjustable. These permanent timeouts on shared hosting help ensure that if there are ever any runaway scripts that aren’t being monitored, they will not impact performance for any great length of time. But of course, they can be problematic to deal with when you are monitoring something and want to import data that will take quite some time.
The solution is wp-cli
WP-CLI is a command line method of working with WordPress. Rather than invoking the import command using a URL, you do so when logged in via SSH which bypasses nginx, apache, fastcgi, and php timeouts since it doesn’t use anything but straight-up PHP to run.
This guide is specific to running this on a Plesk server. It is an advanced guide because you must be familiar with connecting to your server via SSH and using the command line to use it.
1] Get your Export File
Download export file from source site by logging in to the WordPress admin then choosing Tools > Export. You can download all content, or just specific content if you wish by selecting the type of content you wish to export.
If you choose specific content (like posts) and there are images in your content, you will not be able to transfer them without also making an export of type “Media”
2] Upload export file in Plesk
- Login to Plesk
- Find the domain you wish to import to, then select “Files” to go to the Plesk file manager. You should be looking at the WordPress files like wp-config.php and the wp-content folder.
- Drag and drop the WordPress XML export file into the file manager to upload it.
You can, of course, also upload via FTP/SFTP if you prefer that method.
3] Set up Environment & Import
- Learn how to install wp-cli for your Plesk hosting here.
- Run this to import the xml file:
php wp-cli.phar --authors=create import
If you have multiple XML files (like one for posts and one for media), repeat this for each of them.
If there is any problems during the import (like the process is killed) you can always re-run it. In all cases where I’ve had to do this, the import utility has skipped over existing imported items and resumed where it left off.
That’s it! This guide shows you how to import your WordPress XML exports by using CLI to avoid web server timeouts.