Keep database synced between computers in Trellis/Bedrock/Sage setup

Thank you @blu! I can confirm that works as expected. :clap:t3:

EDIT: Updating Vagrant to version >2.0.4 can lead to some unexpected behavior such as Trellis not recognizing the installed plugins like “vagrant-hostmanager”. For reference:

@pacotole, I just tested trellis-simple-sync on my site, and it works, thanks! Running your sync was quite an effective check on my Staging site setup as I had somehow managed to set it up incorrectly, but yet it was working. All good now.

I have a question:

You only run one search-replace command of the format:

"wp", "search-replace", "https://example.local", "https://staging.example.com", "--all-tables"

This works, but does not cover all of my development (example.local) URLs, as many instances exist where the URL is not “https://example.com”. It can be one of:

  1. https://example.local
  2. http://example.local
  3. example.local

I have searched for info on this scenario, but all references to running search=replace only describe URL examples that contain the text “http://” or “https://”.

Do you know if this is a problem with my WordPress site, or if I just need to modify your Ansible scripts to add 2 extra calls to search-replace to cater for http://example.local and example.local?

Also, how do you recommend handling guid columns?

Thanks @henscu

In my case, I use http in development and https in staging/production so I need to change the url with protocol included.

trellis-simple-sync automatically detects if SSL is active in each environment and replace the correct url.

I’ll add an extra search-replace task protocol-relative "//example.com" to ensure all urls are replaced.

Generally, I don’t recommend to change domain without protocol "example.com" because it can be part of the web content, like legal texts or if the domain is the name of the site (e.g.: “Welcome to example.com …”) but in particular cases may be necessary. You can add your extra tasks if needed.

About GUIDs, as far as I know, they are used as a unique identifier in the XML feeds.
If you are syncing a new site between dev <-> staging/production there is no problem.
If you are migrating from an old domain to a new domain and have many subscribers, you should keep the same GUID (wp search-replace ... --skip-columns=guid) to prevent that all old posts appear as new posts on feed readers.

3 Likes