Best way to combine Composer+Wordpress & Roots+Node+Grunt workflows?

Sed works to find and replace URLs that arenā€™t serialized, but widgets and plugins often serialize their entries, so itā€™s possible youā€™ll miss some serialized URLs if you just use sed.

Er, yes. Just learned that the hard way. Thanks :wink:

Iā€™m telling ya, once you get wp-cli installed (Itā€™s included in VVV, along with grunt, Node, Composer), itā€™s a handy tool. To search/replace with whatever URL is already in the db, hereā€™s what I use. It finds the existing URL and replaces it across all tables.

wp search-replace `wp option get home` http://local.domain.com

Equivalent to:

wp search-replace http://www.domain.com http://local.domain.com

But Iā€™ll still say the easiest way to migrate dbs is to use WP Migrate DB Pro. Once you get it set up, you can push/pull databases all over the place with a click of a button, so you can really iterate rapidly between environments.

1 Like

Yes, agreed. Iā€™m using WP Migrate Pro right now. Still not had chance to play with wp-cli but I have it installed.

2 Likes

jplew has a promising script based solution for syncing the WP database and uploads/assets.

Iā€™m just starting a new WP project with Roots (delighted when I found it) and am planning to do git deployment for the first time so Iā€™m quite a noob at all this, but it feels good to be doing things like a Grown Up. At the moment jplewā€™s script is my first choice for tackling the DB/assets dev/prod sync question.

2 Likes

This might be an option:

Havenā€™t used it yet, stumbled upon it a while ago.
Should be the same as Migrate DB Pro, but free.

@mjc, thanks for pointing out SyncDB. That script is essentially a much better way of doing what Iā€™ve hacked together with bash scripts + Search-Replace-DB. Assuming it works, it has the potential to finally complete my automated, fully-CLI workflow for syncing whole WordPress websites. I might even be able to use that for my Magento syncs.

@treb0r all fine with wp db migrate pro? weā€™re considering to get the 100 license in order to solve once for all the serialization problem. What about integrating wp db migrate pro with composer, is it the same plugin code which you install from wp packagist? If not, how to integrate the pro version in composer? Thanks

Er, sorry for the extremely late reply, missed this before.

Just for the record, Iā€™m still using WP Migrate DB Pro and it works fantastically well with Bedrock.

I did toy with the idea of adding a Capistrano task to handle DB migrations but Iā€™ve found that it makes a lot of sense to handle the DB separately. Sometimes you just need to update the theme files or the plugins and you donā€™t need to touch the database.

Iā€™m using the wp-cli add-on for WP Migrate DB pro to schedule nightly backups of all of my client sites back to stage. Works great, canā€™t recommend it enough.

The media files add-on is also really useful.

@treb0r
Not sure if this helps but I use wpcli and some aliases:

dbpullP='be cap production wpcli:db:pull'
dbpullS='be cap staging wpcli:db:pull'
dbpushP='be cap production wpcli:db:push'
dbpushS='be cap staging wpcli:db:push'

Iā€™m newish to all of this, why would I need to do more than this? Is it for purposes of automation when you have to manage lots of sites?

edit: the be is for bundle exec

1 Like

Itā€™s just nice to have the flexibility I guess.

Each to his own, but I do really find that this plugin is indispensable when dealing with multiple copies of the same site.

Hi there, can you confirm that the media files addon works with bedrock? I had wanted to buy a license but didnā€™t go through as I read somewhere in their doc that it wasnā€™t compatible with Wordpress core in its own folder (as it is in bedrock). Thanks

Yes, I can confirm that the media files add-on works great with bedrock.

Iā€™ve been using WP Migrate DB Pro since just after it came out. I have ~50 WP installs active and using it and all of them are built on Bedrock.

Iā€™ve said this before elsewhere on here, but after experimenting with automating DB migrations as part of the deploy process I have come to realise that it makes a lot of sense to handle them separately.

When you get used to using the plugin every day, the license fee starts to feel like a bargain ;-).

2 Likes

+100 to this - itā€™s an amazing tool to have

New tutorial on this, via @brandon:

1 Like

Great idea. Would love to hear more about how you do that. Do you run those via cron? Does that work well as your main backup/restore solution? I already use it as my main db migration toolā€¦ wondering how it may serve as backup strategy, too.

Yes, with cron. Once you have the migration profiles set up in the GUI you can call them using wp-cli.

Iā€™m not actually doing the nightly backups to the staging server(s) at the moment, I think the best way is to have a fourth host just for backups for each live site. We use staging for showing off new features to the client and the backup was getting in the way. I also find that attended backups give me more peace of mind.

All in all, the Sage / Bedrock / WP Migrate DB Pro setup has just totally revolutionised the way I work and Iā€™m extremely grateful to all concerned. Iā€™ve been building websites for a living since 1994 (showing my age!) and this is the first time Iā€™ve felt really confident not just in the building but also in the ongoing maintenance of the client sites.

I know some people who find the rapid pace of change around here off putting, but Iā€™ve embraced it which really keeps me on my toes. Every new evolution brings something amazing to the party. I only just started using Bedrock-Ansible and it has blown my mind :wink:

4 Likes

ā€¦and by the way, yes, you can use WP Migrate DB pro for backups / restores just as easily as you can use it for migrations. You can even just restore specific tables if necessary.

A timely article about scheduling DB backups with WP Migrate DB Pro and Cron: https://deliciousbrains.com/wp-migrate-db-pro/doc/scheduling-migrations-backups-cli-addon/

1 Like

Ha! I was just about to post that article here, too. They are considering an add-on to allow scheduling migrations and backups via the UI. Anyone interested in that should email them so they decide to do it.

So, do I understand correctly that you have a backup server, and you push the migrations there? Does that mean you need to set up working versions of each of your sites there? That seems like a lot of work for a backup solution, but maybe not. Thoughts?