Using the WordPress Importer From the App Engine Plugin

As we announced recently, the new version of our App Engine WordPress Plugin includes import support for WordPress export files, forked from the popular WordPress importer plugin.
This plugin lets you take content that you’ve exported from another WordPress site, in the form of an .xml file, and import it into your App Engine WordPress site.

This post walks through the process of doing such an import. It assumes that you already have a WordPress installation on App Engine— if not, see these instructions.

If you will be doing an import of a large .xml file, see the section below on “What to Do if You Have a Large Import“.  As described in that section, you should make a temporary configuration change to your app before you do the import, to ensure that it finishes successfully.

Update (or install) the App Engine plugin as necessary

If you haven’t updated to use the App Engine plugin v1.3 or above (or don’t yet have it installed), do this first. You can do this by running your WordPress app locally using the development server, installing/updating the plugin via the Dashboard’s plugin page, and re-deploying your app. You can also just download the plugin and unpack/move it into the wordpress/wp-content/plugins directory, then re-deploy. (Note that, as explained here, you can’t update the plugin from your deployed application).

If this is a new installation of the plugin, configure its settings to use a Google Cloud Storage bucket that your application is authorised to connect to, as described here. You’ll need the name of that bucket in the next section.

Export Your Content From Another Site

Once your plugin is installed, you’re ready to do the import. First, go to the WordPress site you want to export from, and generate the XML export file there.
Go to Tools > Export, and choose the XML option:


Export an existing WordPress site’s content as an XML file

Choose what content you want to export, and download the generated XML file. If you click on, e.g., “Posts”, you can select a time range from which to export.


Generate and download the XML file

Upload the Exported Content to Google Cloud Storage

Next, upload the generated .xml file, that you just downloaded, to the Google Cloud Storage (GCS) bucket that you configured in the previous section. Your App Engine app is going to grab it from here when it does the import.

There are multiple ways to do the upload of the .xml file, but probably the easiest is just to visit the Cloud Console for the Cloud project that the bucket belongs to, go to the GCS page via the left navigation bar, and upload the file via your web browser. You can create a subfolder for the import file(s) if you like. Note the path for where you’ve uploaded this file. E.g., in the following, the path is aju-wp.appspot.com/import/amy.wordpress.2014-01-15.xml, where aju-wp-appspot.com is the bucket name.


A WordPress xml file uploaded to GCS for import

Import the XML File

You’re now set to do the import.  If you have a large import, first see the section below  on “What to Do if You Have a Large Import”, and configure your deployed application so that the import does not time out.

Then: Go to Tools > Import in the Dashboard, and choose “Google App Engine”. (If this doesn’t show up, double check that you have the App Engine plugin installed).


Importing using the App Engine plugin

Input the path to the .xml file that you’ve just uploaded to GCS. (The path needs to specify the bucket that your App Engine application is authorized to connect to). Then click “Import from specified file” and follow the instructions from there.


Specify the GCS path to your upload .xml file. (The full path is not displayed in this screenshot).

Media Attachments

When specifying what to import, tick the “attachments” box if you want to pull in your media uploads from your old site into your App Engine site, where they’ll be stored in your linked Cloud Storage bucket.

If you opt to import media attachments from your old site, you may need to do some editing of some of the posts that reference this media. Specifically, if a resized version of an uploaded image was included in a post, the importer will generate a non-valid link, and you will need to re-add that image to your post.
The (invalid) importer-generated link will look something like this

https://storage.googleapis.com/<your-bucket>/imagename-300x300.jpeg

The App Engine plugin does image resizing differently, and these links don’t work. So, you’ll need to locate that image in the media library, and re-add it to the post, setting it to be the display size you want (and removing the old image link).

What to Do if You Have a Large Import or See an Import Error

If you have a large import file, its processing might time out. This is because App Engine’s default “front-end” instances have a request deadline of 60 seconds. If this happens, you’ll get an import error.

The easiest way to handle this is to temporarily configure your WordPress application to serve from a manually-scaled backend, as described below, so the import request won’t time out. Then, do the import followed by redeploying the application to get back to the original state once the import is finished. (It’s not a problem if you’ve already had a timeout on a partial import— the importer is smart enough to detect duplicates).

This process is straightforward, and requires you to temporarily modify your app.yaml file.
Make the following changes.

First, add the following start handler definition to your app.yaml if it is not already there. Put it at the top of the list of handlers. (Make sure the wordpress/wp-content/index.php file is there – it should be).

- url: /_ah/start
  script: wordpress/wp-content/index.php

It’s important to ensure that the start handler is defined as above. The manually scaled backend requires a call to /_ah/start/ to complete successfully, and for some configurations of WordPress, the application will not deploy if the start handler defaults to ‘/’ (because of some URL rewriting).

Next, define the ‘default’ module to be a manually scaled backend, by modifying the top section of the file. Change this section from:

application: your-app-id
version: uno
runtime: php
api_version: 1
threadsafe: false

to look like the following (edited for your application id and version name):

application: your-app-id
version: uno
runtime: php
api_version: 1
threadsafe: false
module: default
default_expiration: "1d"

instance_class: B8
manual_scaling:
  instances: 1

After you’ve made these changes, redeploy your application, and rerun the import.

Then, revert your changes, so that the start of your app.yaml file again looks like this (again, modified for your application id and version name):

application: your-app-id
version: uno
runtime: php
api_version: 1
threadsafe: false

Then redeploy your application. Be sure to do this after the import, so that your app can again autoscale as normal.

One thought on “Using the WordPress Importer From the App Engine Plugin

Comments are closed.