I'm trying to transfer a WordPress site to a new server, but I've looking to do it in a clean way. Although, I can simply dump the database and transfer it to the new server, I would like to find a way to only transfer the what's necessary to start from scratch, such as posts with custom fields and settings, images, and attachment information. Then I want to configure the plugins and settings manually again.

Is there a way to accomplish this task?

I have tried using using the WordPress importer, but if I tried to a dump of everything, the import will not work complete successfully for 7000 posts, and if I try to export the posts and the media, then the image attachment ("Uploaded to this post" option in the upload media from the post editor) to post will go missing.

3 Answers 3


Strategy for cleaning up

To give a high level answer to your question, there basically isn't a way to achieve this completely cleanly with Wordpress. The reason for this is that Wordpress doesn't enforce a 'contract' for the data structure with its themes or plugins. There's no way Wordpress core can say 'Plugin, tell me exactly what database tables and fields you use' so that it could then know exactly what data to move or delete for that plugin. So there's no way you can know this either in a quick, clean way.

Because of this, cleaning up will always be a manual and imperfect task in Wordpress, unless you review the code of your plugins and theme in detail to figure out where the data is and how it's connected, but this would probably take a long time.

You might remove something that you need, or you might leave behind something you don't need.

With this in mind, I would suggest making your life as easy as possible. Figure out some goals that are important to you and optimise your time to those. Otherwise you may spend a lot of time to make small changes that don't actually give you much benefit for your situation.

For example, things you might want to:

  • Reduce disk space used
  • Reduce size of database
  • Decrease page load time
  • Decrease server load
  • Remove plugins which cause errors
  • Remove unused items from Media Library UI

If you get your site in a broken state you may have a huge piece of work to fix it, which is why I'd strongly recommend making a perfect copy, then optimising just the things you actually need to.

How to do transfer in your case

I would recommend firstly doing a complete transfer of your site to a temporary location where you can work on it safely. As you said, dump and restore the whole database, or perhaps use a plugin for transferring sites, copy the entire file system, do the settings updates required to make your site work on a temporary URL. There are lots of resource on how to do this.

Then fix whatever you need to fix and don't worry about anything else and keep things in a working state. Test often after you make changes and be able to revert easily so you can make small incremental changes, test quickly, go back if it's broken.

I suggest it a lot, but Query Monitor will get you a good quick view of what's loaded and when.

Then for other specific goals you can probably find answers here for specific things quickly. E.g. removing unused media items

I hope that's helpful, and perhaps others will have answers on being able to cleanly remove / optimise other parts of your Wordpress install.

  • Useful info. Thanks. The site is currently working, but I've dealing with some MySQL issues in the past, and even though things seem to be OK now, I'm still skeptical something is not right in the db. So, I haven't been doing a lot of maintenance, because sometime I think I'll provoke the db to go crazy. Now, I'm seeing that cpu is spiking with because of apache, so I on doing a clean transfer to see if everything goes back to normal. The crazy thing is that I've testing different ways to clean transfer for weeks, and there's always something not working.
    – mhweb
    Jul 11, 2020 at 14:21
  • My take away from your answer is that I'm not I don't know the process. Instead, it's that there's not a right way to do it. And like you said, even though, I could tried, I wouldn't know if everything I need would transfer to the new server.
    – mhweb
    Jul 11, 2020 at 14:25
  • Do you know if there's a way to scan a MySQL database to make sure nothing goofy is going inside?
    – mhweb
    Jul 11, 2020 at 14:26
  • Yeah, I know what you mean about the feeling that something isn't going right if it's failed before. The best way to feel better about these things is to put numbers on them so you can see e.g. if you have long running queries or if there are a lot of errors sometimes. If everything looks ok and your site is working, it's probably ok ;-)
    – mozboz
    Jul 11, 2020 at 14:28
  • 1
    What do you mean goofy? ;-) You will definitely notice if something is broken, so for anything that's not definitely broken you probably have to be a bit more specific. E.g. do you get lots of errors sometimes? Are some specific pages really slow? I'm reasonably familiar with mysql and I've never had to run a command just to check if MySQL is 'ok'
    – mozboz
    Jul 11, 2020 at 14:30

as mentioned, SQL syntax is very specific. Is a comma or a bracket is out of place; it will not bother trying to figure it out. It will just error out completely and not run the query.

So, I don't think something as simple as a syntax error is causing your CPU spikes.

First, focus on trying to identify as best you can what service is causing the CPU spike. If you have access to the machine which this lives; there are many tools that can help here.

Second, I have seen situations where someone programed a plugin badly and the plugin is storing large images or other binary data. And very large amounts of it at that. However, if anything like that happened in the past and that data is still living in your database; you should be able to easily find it if you look for large chunks of data in your DB. Additionally, you can use different clients to explore the DB. But also remember, that if you are no longer accessing that data (i.e. turned off the offending plugin); then you should not be having too many problems.

I guess the biggest question like many have, is what is the problem. What is going on badly with with the website besides your feeling that something is wrong? Is it quantifiable in anyway in actual functionality of the website?

Cheers, T

  • 1
    The most immediate problem is the apache processes randomly spiking the CPU. In the older server, the cpu would stay flat and constant between 4-10% tops, now it can peek 100 for a while and then it calms down. Also, I still not not sure if mysql still have problems, for years I'm been using phpmyadmin and/or plugin to clean up the db, and since I start to have RAM issues with older server, I transferred the site to newer ubuntu and mysql 8, every time I wanted to clean up the db, mysql goes crazy. Now things are working, because I haven't mess around with the vm or cleaning up vm.
    – mhweb
    Jul 11, 2020 at 22:09
  • When you say mysql goes crazy; what do you mean by that exactly? I had a similar issue where I moved a few sites (4 to 6) to a VM instance on Google Cloud. This would have been only temporary while I was making a new setup for them to eventually live it. At the time, I figured these sites were pretty small and not really busy. And so, I gave the VM only 4 gigs of RAM. Back in the day. And I mean back in the day (like 90s); you could run a couple of 100 sites on 4 gigs. LOL ... Anyway, found out that MariaDB (which was the MySQL that I was using) uses up 4 GIGs just to load up. Jul 11, 2020 at 23:18
  • So, RAM maybe an issue. Issue I had was MariaDB would write to disk to conserve memory constantly and not answer apache and everything would grind to a halt. Jul 11, 2020 at 23:19
  • With crazy I mean high cpu usage for unknown reason to me, even after changing theme and disabling all plugins. Of course, when this happens I get all slow queries, so checking which query is causing the problem is hard, because every query takes a long time when cpu goes high.
    – mhweb
    Jul 12, 2020 at 13:04
  • 1
    The ram issue was original problem, then mysql and apache problems started I transferred the site to new server that had newer software. The ram issue stopped after the first transfer.
    – mhweb
    Jul 12, 2020 at 13:07

If I was moving to a new host (or even doing a new upgrade), I'd use a cloner like Clone (Automaticc) plugin to copy entire site, content, images, etc to a new place. ("Clone" zips everything, and then you import that into a new/fresh install. Works quite well, and fast.)

Then, I'd delete any unneeded plugins and themes, then do a mass delete of posts and pages I didn't want, ending up with the base system plus the posts/pages I wanted to retain.

Then, install a new theme (if desired), configure it, add plugins as needed. Once all is done and tested, use your hosting's cPanel to assign the domain name to that new folder.

A bit more work, but unless you are really good with SQL commands, less chance of screwing up the database and other things.

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.