Creating local WordPress sandbox, importing site, pushing changes back to live server

Tags:

Hello, this subject keeps coming up. It is how do I work on sites without breaking the live thing. Then taking the changes and pushing them into production.

This is the method that I use. There are hundreds of ways to do this. This is just my preferred.

Steps

Install "all-in-one-wp-migration"

First step is to use this plugin by ServMask. It is rock solid. The free version supports sites up to 500MB in size. That might not sound like a lot but it is enough in most cases.

Install and activate from the wordpress plugin repository.

Once installed click "backup location" = "local". This will archive every single thing that is in the site. It will wrap it up into a nice file with a .wpress file extension

If your site exceeds the free limit of "all-in-one-wp-migration"

There is hope. You do not need the pro version. If you want to support the company and save some time then by all means show the dev's some love.

If you want to go another route that is more time consuming then use the native import/export function of WordPress.

Steps

This method is not preferred because if there is an issue then you have no tidy backup file to lean on.

However, I have done it multiple times with no problem

Spin up local Bitnami WordPress LAMP stack in a virtual machine

Go to Bitnami wordpress stack -> virtual machine. Download the virtual disk file

Download VirtualBox. It is available for Linux, mac, and windows

Import the virtual disk into a new VM

Make sure to change the networking to "bridged" also if needed change the disk space size.

Import live site to virtual machine

If you used all-in-one then the plugin will be preinstalled on the new stack. All you need to do is select the backup and let it do its thing.

If you used the wordpress native import/export then follow the above steps.

After all is complete the sandbox might not load. That is where the next step comes in

Change hosts file to point to vm

The "hosts" file on your computer enables hard DNS overrides. You can tell your computer to, when resolving a domain, resolve here instead of live dns records.

We do this with the sandbox because it prevents having to change the sandbox wordpress install domain. Saving time and ensuring a smooth transition back to the live server.

So simply go to the hosts file and change it to resolve the domain to the local IP of the sandbox.

You can find the sandbox IP by typing "ip a" in the console or looking at dhcp leases on your router.

Now you just work on the site

Easy enough right? there are some corks. Mostly that if it is an Elementor site with pro Elementor the license will not be active. There is no way to activate it except changing the WordPress install domain to something.dev

That is very annoying. For most plugins they will behave normally. I have never found one as tight fisted as Elementor.

Otherwise. If you need to visit the live site just change back the hosts file to not manually resolve the domain

Export site back to production

Now the scary part. Overriding a live site. This can be nerve racking but just remember that you have a copy of the original files on the server.

If you used all-in-one then the original .wpress file will still be on the server. If you used the alternative method then you have the files downloaded.

Well when you are ready, take a backup of the staging site and reupload it to the live site. If you used the native method then you will also need to upload images to the live server separately. There is no automatic method for the live site to grab images from the sandbox.

Now you are done. Yes there is likely a more smooth way to do this, however this just works

Everyone has an opinion on how to do this best. Some use all online sandbox sites. This way is free. Some hosts have sandbox services, some do not.

Whatever the case the above methods will work every time. Regardless of hosts.

Any questions leave them bellow.

Leave a Reply

Your email address will not be published. Required fields are marked *

We Would Love to Help

Web design. IT computer network systems. Security Cameras. Graphic design. We do it all. Reach out to see if we are a good fit for you.
menuchevron-down linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram