Working with 2 VPS's - Staging and Production - How to copy from one to another

Hi guys!

I need a bit of advice from devs on how to handle this situation, please.
I have to VPS’s a staging and a production one. They’re both identical running same OS’s.
On the Staging VPS I have a dummy domain where I develop an e-commerce site and I test functionalities, etc.
On the Production VPS, I have the desired domain that is accepting connections from the public.

When build stuff on the Staging and all works well, I want an easy way to migrate a copy of the site from Staging VPS to Production VPS.

How can I do that simple?
How to change the URL of the site from Staging to Production and how to make sure everything is migrated nicely. Is there an ee command to update the URL as it used to be before?

I use Digital Ocean droplets.

Thanks!

There’s no golden bullet and WP database migration is always a pain and as we found out over time more and more project fails to sync live and staging DB.

But in a nutshell you need:

RSYNC to migrate your files:

rsync -avz --progress usernam@DEVSERVERIPADDRESS:/your/staging/web/path/* /your/live/web/path

You need to export the database and you can use admin tools to import it. Lastly, log in to your docker container and replace your links

ee shell example.com --command='wp search-replace "www.oldlink.com" "www.newlink.com"'

Just heads up - I free-typed it so double check yourself, but it should give you an idea.

If you’re working with just WordPress websites, Roots Trellis and Bedrock are brilliant for staging and production parity. I use both on one of my WP servers. I recently upgraded the server from Ubuntu 16.04 LTS to 18.04 LTS with four Terminal commands (provision the server, deploy the WordPress website, then push the database and uploads). So easy.

It’s an entirely different concept to EE4, but once you’ve mastered it it’s a good option to have if you’re in the WordPress dev business.

Good tip! Thanks I will look into it

Hi ralf,

I’ve migrated the site but the in ee site list I can only see the old site name.
How do I get ee to replace the site name in site list?

You don’t - you need to create a new site - when you’re migrating you need to have environment of the new (live) site. The changes apply only to the DB. It’s not wise to transfer any config files or system files (including nginx/docker) between servers.
So you need to create a new site with live URL then migrate files and DB and then do search and replace in the DB on the new site.

One of the easiest options is using Updraft Plugin, they have a migration part where a backup is taken of the site you want to migrate and then pushes all the stuff to the new site, changing URL’s and everything. You can also just take a backup in zip format, upload it to the new server in Updraft folder and then restore the new site from that. For more advanced workflows, I think Bedrock and Trellis are better though.

I have certainly done my fair share of rsync and wp db export|import command line wrangling. About a year ago I found a commercial plugin called WP MIGRATE PRO and it worked great. It does a fantastic job of allowing one to sync databases between different environments with a simple push/pull nomenclature, it handles the renaming of links in the db and it handles the synching of the uploads directory. I have used this plugin on both easyengine sites as well as Trellis/Bedrock sites. What I failed to realize until about a month ago is that there is a GPL port of that plugin on Github. Now you can get this great plugin minus the $100 costs. Go to the Github page and check out their description and videos.

*NB I have no affiliation with the plugin or the commercial version WP Migrate Pro outside of being a super happy user. I realize that for the command line junkies in the forums this may be a slap in the face to use a plugin. But when it comes time to pass off projects to customers, a plugin like this one assures that you at least have a fighting change to get the customer to continue to utilize a staging-production workflow.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.