[转载]Importing and Exporting Large WordPress Blogs

[转载]Importing and Exporting Large WordPress Blogs | Blink 7.

WordPress created the import and export admin functions to make the task of moving posts, comments and categories between blogs relatively simple. No longer did one have to be a database expert to cleanly transfer content from one blog to another, while creating backups of written content became a trivial exercise with WordPress’ custom XML files. While the import and export functions work fine with small to medium-sized blogs, extra configuration is often required to address the various errors that occur when working with data from blogs with a high volume of posts and/or comments.

This tutorial reviews the process of transferring content from one WordPress site to another with an emphasis on how to handle the import/export of larger blogs. Some of the solutions require PHP configuration (accomplished by changing the php.ini file on the server) or manipulation of the WordPress XML data file.

Pre-Requisites

Before attempting to follow this tutorial, please make sure you have the following.

  • Administrator access to both the source and destination WordPress sites. The destination site should be a freshly-installed copy of WordPress (v2.7 or higher)
  • FTP access to the destination site
  • If possible, FTP access to the source site (not available on wordpress.com sites)

Downloads

(download) Sample php.ini file
(link) Optional: Filezilla (free FTP client)
(link) Optional: Notepad++ (free text editor with xml support)

Exporting from the Source Site

Wordpress Tutorial - Importing and Exporting Data

Type in URL for the admin page
If your WordPress blog’s URL is www.mysite.com then your admin URL would be www.mysite.com/wp-admin/
Log in as an administrator.

Wordpress Tutorial - Importing and Exporting Data

Click on the Tools menu item (WordPress 2.7.x places the admin menu along the left side of the screen)
Click on the Export sub-menu item

Wordpress Tutorial - Importing and Exporting Data

(optional) If you want to export the posts by a single author, click on the drop-down box beside the “Restrict Author”. Select the author.

Wordpress Tutorial - Importing and Exporting Data

Click on the Download Export File button.

Wordpress Tutorial - Importing and Exporting Data

Ensure the “Save to Disk” radio option is selected.
Click OK to save the XML file to disk

Wordpress Tutorial - Importing and Exporting Data

Open the XML file in a text editor. Make sure the last lines in the file consist of the following tags:

</channel>
</rss>

These close tags suggest that the file has been fully downloaded.
If you do not see these tags at the end of your file or you see an HTML 500 Internal Server Error message embedded in the XML file, see the Troubleshooting section.

Importing to the Destination Site

Wordpress Tutorial - Importing and Exporting Data

Type in URL for the admin page
If your WordPress blog’s URL is www.mynewsite.com then your admin URL would be www.mynewsite.com/wp-admin/

Wordpress Tutorial - Importing and Exporting Data

Click on the Tools menu item (WordPress 2.7.x places the admin menu along the left side of the screen)
Click on the Import sub-menu item

Wordpress Tutorial - Importing and Exporting Data

Click on “Wordpress”

Wordpress Tutorial - Importing and Exporting Data

Verify that the maximum allowed file size for upload is larger than the size of your WordPress XML file. If not, proceed to the troubleshooting section.
Otherwise, click on the browse button

Wordpress Tutorial - Importing and Exporting Data

Select the XML file created during the import process. Click the Open button

Wordpress Tutorial - Importing and Exporting Data

Click the Upload and Import button. Processing may take a few minutes.
If the import was successful, the screen will eventually display a list of the posts in the xml, along with how many comments were associated with the post and how whether the post was successfully imported.

Click on the menu option Posts to verify that the import was successful.

Troubleshooting

Problem: The export File did not finish downloading

If the source website is a self-installed copy of WordPress, note the php.ini file can be altered to extend the amount of time PHP will allow for a script to be processed. To make this change, load the php.ini file into your text editor and set the variable max_execution_time to a higher value. Upload the updated .ini file to /wp-admin directory of the source website. Numeric values are in seconds. The .ini file provided with this tutorial is set to 500 seconds, which was sufficient for producing a 50MB XML file.

If your source website is on wordpress.com then simply try downloading the file again.

Problem: The XML file larger than the max file size on the import screen

The maximum upload file size is determined by the upload_max_filesize variable, located inside the php.ini file. The sample .ini file that comes with this tutorial has the max upload set to 100 megabytes, which should be enough for just about any site. If you already have a php.ini file then you can adjust the variable to be just larger than the file you wish to upload. Megabyte denominations are marked with a capital M – for instance, if you wanted the maximum upload size to be 60 megabytes, then you would set upload_max_filesize equal to 60M.

Alternatively, you could split the XML file into several XML files that are smaller than the upload limit. Note that splitting an XML file is not as simple as physically partitioning the file – the header and trailer must be present in each file. One relatively safe way to split the file is to make x copies of the file and strategically delete posts from the middle of each file (posts are enclosed in the and tags). For instance, to split the XML file into 2 pieces you could make a copy of the file then delete the first half of the posts from the first file and the second half of the posts from the second file. After importing both files you should have all your posts in the destination site. WordPress will ignore duplicate posts or channels during import, so there’s little risk in overlapping information between files.

Problem: During import, a 500 Internal Server Error appears

If you have an especially large import file (20MB or more) the server could running into a processing limit related to the amount of data being extracted from the source website. Most PHP installations place a cap on the amount of data that can be uploaded via a POST query.

Once again, this problem could be solved by splitting the XML file into several smaller files (smaller imports files means less data to be posted).

Alternatively, you could alter the php.ini file to allow more data to be uploaded via POST query. Find the variable post_max_size and increase its value. Megabyte denominations are marked with a capital M – for instance, if you wanted the maximum data processed to be 70 megabytes, then you would set post_max_size equal to 70M.

Problem: The uploaded php.ini file does not seem to be making any difference

To verify that this is the problem, change the value for variable post_max_size to some unusual value (e.g. 41M, which will be interpreted as 41 megabytes) and re-upload the file. Refresh the import interface. If the upload max size does not change, then PHP is not picking up the .ini file.

First, verify that the .ini file was uploaded to the /wp-admin sub-directory of the destination WordPress installation.

If the max file upload still isn’t changing, try uploading the same .ini file to the html root directory on your web server. Some shared hosting solutions, like those provided by BlueHost.com, require that you put a copy of a custom php.ini file in the html document root and then another of that file in any directory where you wish to use the custom settings. If you do not own the web account then you may have to provide the .ini file to the account owner to upload. Typically, root folder name is public_html.

If the max file upload still isn’t changing, then custom php.ini settings may be disabled on your server. Contact technical support for more assistance. Some hosts will even run the script for you.

赞(0) 打赏
分享到: 更多 (0)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏