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
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.
Yes, agreed. Iām using WP Migrate Pro right now. Still not had chance to play with wp-cli but I have it installed.
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.
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
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 ;-).
+100 to this - itās an amazing tool to have
New tutorial on this, via @brandon:
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
ā¦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/
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?