• Skip to content
  • Skip to secondary menu
  • Skip to primary sidebar
  • Home
  • About
  • Contact
  • Deals

Ryan Rudolph

Front-End WordPress Developer

  • Tutorials
  • Genesis
  • WordPress
  • CSS
  • Plugins
  • Web Design
  • Events

Keeping WordPress In Sync Between Local And Staging

May 14, 2016 by Ryan Rudolph Leave a Comment

Remember your amateur days of cowboy coding in WordPress? Tedious scenarios of editing website files directly from FTP. Every press of the refresh button could risk your website magically disappearing. Those days are over. There’s a lot of great tools that keep you in full power of your website, ensuring local files and data is up to date.

Synchronizing files and databases across environments is not easy to wrap your head around at first. There’s many different moving parts and steps involved, that once understood, makes the whole process seem simple.

Keeping Local Updated Is Not Only Necessary But Imperative

Here’s an example. John has been building a website about cats for 5 weeks now. John has just placed the website on a development server where the clients can view the progress of the site. Once the clients give him a document of changes, John kicks into full gear. He makes the revisions on his local machine making sure everything requested is complete. He then uploads the entire site to the development server, overwriting the old development version.

Now this process works in some cases, but it’s time consuming and inefficient. Imagine the client has a few sentences to change, and John has to upload the entire site again. Or what if the client has been upload content to the website, such as blog posts or cat descriptions. John can’t upload his version or he’ll override their changes.

Although there’s a lot of tools out there for this workflow, there’s one that I’ve found particularly useful:

Migrate DB Pro – A premium plugin used to push and pull databases from servers. This is the golden piece of the puzzle. There’s alternatives like WP-CLI, but most of the article is specific to this plugin.

So let’s get started.

Updating Files

At this point your website should be in two places, your machine and the development server the client is viewing. Once you make the website revisions locally you will want to setup a Git remote to allow you to update the files. In my workflow I use WP Engine and make use of their Git Push feature. If you need help doing this with WP Engine specifically here is an article on what’s involved: Using Git With WP Engine: Outlining The Process.

This seems like a tedious process but is amazing in the long run. No more connecting to the FTP server and uploading the files over a period of 5~20 minutes. Enter four simple words in Terminal and watch it go to work.

git push name_of_remote name_of_branch

name_of_remote is generally “origin” or “production”, while name_of_branch is generally “master” or “staging”.

If you’re not using version control, that’s okay. You will update the files the old fashioned way through FTP.

Updating Database

Install WP Migrate DB Pro, and WP Migrate DB Pro Media Files on both the local and development website. Activate the license keys and update the plugins to their latest versions. You will use these plugins when you need to either:

1) Pull – Update the local website with content that has changed on the development website. This it typical when the client or someone else in your company is adding content. You would want to pull this down before you start working locally so that way you push later, you’re not overwriting anything.

2) Push – Update the development site with content that has changed on the local website. This is typical when you have been updating everything yourself on your machine.

Always think before you push or pull! Has anything been changed that you could overwrite? Sometimes you have to be proactive about who’s doing what or you risk stepping on each others toes.

Login to both WordPress sites, enable permissions in the settings of the WP Migrate DB Pro plugin dependent on whether you’re pushing or pulling. Input the connection data and sync your databases.

Here’s a recap:

  • Make the changes on your local version of the site.
  • Commit the changes in your git repository.
  • Push the files up to the development server.
  • Push the database up.

I hope this wasn’t too confusing. The hardest part is determining what’s best for your current scenario/project. Good luck!

Share this:

Related Posts

  • Using Git With WP Engine
    Using Git With WP Engine: Outlining The Process

    Being relatively new to version control, figuring out WP Engine's Git Push feature was a daunting challenge at first. Reading through multiple guides and resources…

  • Google Analytics
    Setting Up Google Analytics On Your WordPress Site Using a Hook

    There's a number of different ways you can install Google Analytics on your WordPress site. There is a way to install it in the functions.php…

Filed Under: Featured, Tutorials

Affiliate Disclosure: All of my posts are 100% honest and genuine. However, I may earn money from the companies mentioned in this post.

Reader Interactions

Leave a Reply Cancel reply

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

Primary Sidebar

Social

  • GitHub
  • Twitter

February Special

20% OFF
newcustomer
migrate db pro

WP Migrate DB Pro

Save time and become a better developer with 20% off their developer package. Code newcustomer applied at the link below.
Expires March 31, 2019
Get This Deal

© Copyright 2019 Ryan Rudolph. All Rights Reserved. Privacy Policy.