we have a staging server in order to test out plugins and roll out new features and also re designing sites. The issue is that the staging version of the site will be out of sync as soon as new content is done on live site, or a new image is uploaded. What is the best way to keep the staging version in sync with the live one, including all posts, images and plugins as well as the whole database in general.
-
Possible duplicate of Database synchronization between dev/staging and production– Jacob PeattieCommented Nov 20, 2018 at 14:44
-
I use WP Migrate DB Pro and it works extremely well. There is even an option to not change the activated plugin settings that seems like it would help in your case.– Fencer04Commented Nov 20, 2018 at 18:08
-
1@JacobPeattie - technically it's a duplicate, but that post is also 8 years old.– butlerblogCommented Nov 20, 2018 at 20:43
-
WP Migrate DB Pro is made to replace one db with another. It does not address the needs of this question. If you copy staging db and overwrite production db, all those sales transactions that occurred in the mean time on the production db will be overwritten.– TARKUSCommented Nov 25, 2020 at 14:17
2 Answers
If you are using Pantheon for hosting it turns out to be trivial to do this as a test (they call it dev
), stage (they call it test
) and production server are built into their platform along with tools to manage moving data and files around. Plus with Pantheon you get easy but optional Git deploy as part of the deal.
You can test out Pantheon for free as you only have to pay for sites once you get ready to deploy to a production domain. Also, if you build sites for other people you can become a partner and unlike discounted partner rates for your clients.
If you are not on Pantheon, and cannot move, then for moving the DB down from the live server to staging I would recommend using a SQL tool like Navicat for MySQL (great transfer tools), DataGrip (great UX but not so great transfer tools), Sequel Pro (free for Mac, not as feature rich) or HeidiSQL (free, for Win, not as feature rich).
And for source code (plugins, themes, etc) and uploads I would recommend a plain-old STFP client, of which there are (too) many.
If you use the Mediatemple staging feature (or GoDaddy, is the same parent company)
Then the short answer is: No, for a silly reason you can't
The use case they had in mind probably was: Do all the changes in dev and publish them to prod, but apparently that doesn't work obviously for stores, etc. where you obviously generate new data in production environment.
The best approach is to generate new zip files from prod (Files & DB) delete the old staging site, create a new one and set it up again with the files from prod.
Now if you don't want to use such feauture, best thing would be to set up overnight cronjobs which do this very same approach overnight so at least every morning you work with the most actual state...
Problem with this approach is that uncommited changes to production will be deleted overnight...
So whatever way you choose there's caveats...