VersionPress database sync not working - wordpress

I'm trying to setup a dev+dev/staging/prod environment with Wordpress. I'm developing local on two Mac workstations (2 local developers) with MAMP. And I have a production server on Cloud. I installed the Wordpress site on my MAMP and cloned it on the other workstation and on cloud. I set GIT to not sync wp-config.php and I made it so that the two workstation and the prod site have the proper DB connection. All 3 site works. I can sync files with Bitbucket with no problem. I setup the VersionPress plugin on all 3 sites assigning the proper name: dev1, dev2 and production. On the Wordpress control panel I see that VersionPress is working, each clone can rollback changes. When I commit things in SourceTree/Bitbucket I see the database changes made by the other dev and the prod site, i.e. [VP] Published post "Test1".
The problem is that the artcle made by Dev1 is not visible on Dev2 or Prod and vice versa. So if from my local MAMP, I log into Wordpress and go to Articles, I can't see the Test article made on the other cloned Wordpress site on our other workstation.
I should be 100% VersionPress compliant, and by the way in the VersionPress setup screen I had all check marked as good with the grey "V" icon.
Am I missing something?
Note: after installing VersionPress a lot of new .git and .gitignore were automatically populated, I guess that's okay, but I haven't touch them.
Other nore: VersionPress is amazing, for those who don't know it I strongly recommend it: https://versionpress.net/ I can't wait to have it 100% functional...

You should clone the sites using VersionPress, specifically its wp vp clone command. Then, you need to push and pull between environments using the other WP-CLI commands, wp vp push and wp vp pull.
The syncing will not work if you installed VersionPress separately on three already existing clones of a site.

Related

Setup for Wordpress + Plesk + Git + Local Environment

I need to update a development environment which exists for multiple Wordpress sites (existing and new ones) and which uses Plesk. Now Git should be used for version control.
Right now every change is done on the stage system, which is not good.
Description of the situation:
Themes which will be used are completely self developed and therefore Git should be used as version control.
The management of the sites is done with Plesk (Production and Stage version).
Sometimes (depending on the site owner) the most recent content is on the production site and sometimes on the stage site (site owner is updating content there) and must be transfered to production.
With the introduction of Git a local environment for every developers is needed (to locally develop and then push the changes to Git), to setup different sites from Plesk on a local environment I would choose MAMP?
Plesk offers a connection between Git (Gitlab in our case) and Plesk so commits will be automatically fetched by Plesk's Stage and Production environments and are published depending on the settings.
So the Workflow (and included questions) may be the following:
Setup new site on Plesk and download fresh stage state to local MAMP.
Create a repository on Gitlab and connect stage branch to Plesk stage site and main branch to Plesk production site.
Local Git folder will be the wordpress folder. Gitignore will ignore everything except the theme folder and the plugin folder (only plugins which have custom changes)
Working locally on stage branch and commiting will result in automatically updating the stage system on plesk.
The production page will not be updated automatically, this has to be done manually because this scenario varies from site to site.
Problems:
Migrating stuff to the production site will be only possible with a manual task I guess, because there is no possibility for customising the pipeline on gitlab as far as I know?
Don't know what to do with content images. Should they be ignored in the Git repo? Currently I would say yes if it's not template related?
Does this sound as a proper way or do I oversee some obstacles here or is there something which can be done in an easier way like the local setup for a new developer on an existing site. As there is only part of the Wordpress stuff in Git, the database and the rest of wordpress have to be copied from somewhere (e.g Plesk' Stage site).
In general the dev setup, deployment and version control with wordpress sites seems a little bit odd for me compared to others like webapps, mobile apps or backend services.
I've used git as version control for the whole WP installation and individual themes/plugins. Under normal circumstances, I don't see the point for the first option, unless you want to keep all the plugins and WP version in sync with the git repo. In that case, you should definitely gitingore the upload folder, otherwise uploading any attachment will cause a mess.
The automate the deploy, you can configure a webhook:
https://conetix.com.au/support/automatic-git-deployments-via-gitlab-to-plesk-based-hosting/

Ho to configure WordPress with GitLab

I'm pretty new to this, but I want to configure my GitLab repo to my Cpanel hosting account. So when I push changes from my local site (environment using local by flywheel) to GitLab it automatically goes to the staging site and if everything is good to the production site.
I have managed to connect my Cpanel account with GitLab by using Deploy HQ. However, I'm trying to understand the best way to set all of this up. Currently, I'm only tracking my themes folder in GitLab. My issue is that when I deploy, all that is getting uploaded is the themes folder(obviously). How do I set this up so it will upload the full WordPress site and database? Also, how do I set it up with staging and production, would I have two different branches connected to two different directories on cpanel?
I'm just looking for some noob friendly advice on how to set up this infrastructure for WordPress Git and Cpanel.

Developing on plesk

Trying to figure the best way to develop on plesk.
I would like to develop my wordpress website on a temporary url, and attach the production domain only when I am done developing.
From some reason I'm getting various dns errors, saw a guide referring to change of hosts file but it dosent seem like the perfect solution to me.
Any tips?
You may create the clone of your WP instance (staging) and use Plesk Git extension for developing this staging WP site. After making all necessary changes on staging non-public clone you can publish it to a production domain to make it publicly available.

Using git with Wordpress and multiple people: access all files locally but only edit a subset?

git n00b here. My boss and I are developing a wordpress workflow with git. We'd like to have a copy of all the files on our local machines, but 95% of time we only want to edit a certain theme folder. But our efforts so far haven't yielded a working solution yet. Here's what I've tried:
I originally set my repository to include all wordpress files, so I could always get latest core files from server. Then I discovered files on server were getting overwritten by local copies even if I didn't edit them (eg i do a wordpress update on server and next time I push from local, the old files overwrite the newer ones on server)
So I used git ignore to drill all the way down to my theme folder. Git was still tracking them, so I used rm to stop tracking. But then git deleted all the other files.
How do people here use git with multiple people to update Wordpress? Any perspectives much appreciated - thanks!
You should keep all the files in your git repository, but you should avoid doing any modifications directlry on the server.
Your wordpress update should be done on any of your local checkout of the repository and then pushed on the server via git.
Another possibility will be to commit / push the update changes once they have been done on the server, but I would prefer working locally and then deploying the update.

Using git with a PHPFog Wordpress app

I have cloned a copy of my PHPFog Wordpress app to my local machine. I then have a few themes im working on with there own sperate repository. So I copy and paste a theme into my Wordpress repository and then sync it back up with PHPFog.
This works all well and good.
However If I update my Wordpress app in the admin panel, and later on sync up some changes I have made I lose the update, and go back to the version of Wordpress I started with.
How are you supposed to correctly work with git and PHPFOG if every change you make on your Wordpress admin panel gets overwritten with every sync from your local machine.
Am I supposed to update Wordpress and then do another clone in order to have the correct version on my local machine before making new changes, and if that is the case how do clone the updated Wordpress app to my local machine.
Thanks
Your right, file system changes, that are made from the Wordpress admin, do not get added to your PHP Fog repo, and can get blown away on the next push.
A better way to handle this issue is to run your Wordpress installation locally on your development system like you hintted to. I use mamp for mac or wamp or xampp for windows to make changes in the Wordpress admin locally then check in and push those changes. This will let you see the results of your changes without effecting your production site. I think the time invested setting this up is well worth it.
To get this running you should install either mamp or wamp and install a fresh copy of wordpress in order to make sure mysql is running locally and the wordpress installation is able to connect. Then in a new folder clone a fresh copy of your repo and load that up in the browser. The url will be something like localhost:8888. It should fail to find the database but that is expected. You will need to configure your local environment variables (listed below) to point to the locally running mysql server. Look in the wp-config.php file of the fresh install for the database settings. Do not use the wp-config.php settings of your cloned repo. You do not want to make changes to wp-config.php file because those changes will get checked into the repo and it will break your production site after the push.
MYSQL_DB_HOST
MYSQL_DB_NAME
MYSQL_USERNAME
MYSQL_PASSWORD
Here is a great link that explains this process in more detail: http://docs.phpfog.com/getting-started/development

Resources