@swalkinshaw Hi Scott, I was wondering how the new screencast is comming along. I have a new website pending and would love to use what you can teach us for the new deployment.
Thanks again for all your work,
Mauro
@swalkinshaw Hi Scott, I was wondering how the new screencast is comming along. I have a new website pending and would love to use what you can teach us for the new deployment.
Thanks again for all your work,
Mauro
By the end of this week I promise (weekend)! Finally have a good 4-5 days of more time to finish it.
For those waiting on the screencast, Iām 90% done and it looks like Iāll break my promise a bit but the screencast should be up in the next day or two. Unfortunately itās always the editing and final publishing that take the longest
Screencast is finally out! http://roots.io/screencasts/deploying-wordpress-with-capistrano/
Sorry for the long wait but making these screencasts is actually pretty time consuming! Iāll probably start a separate thread for feedback/questions about it.
Awesome stuffs gonna get it when I get back home! Canāt wait!
Iāve made a thread dedicated to the screencast/general Capistrano talk here: Deploying WordPress with Capistrano screencast
Keeping databases in sync in my opinion is one of the more difficult challenges to solve, yet least talked about on forums about deployment. After a ton of different approaches, hereās what I recommend:
WP Migrate DB Pro If youāre a WP developer, itās one of the best ways to spend $99. It is SO easy to push and pull databases between local, dev, prod, etc., including updating URLs that have been serialized in widgets. You can push the entire db, or select which tables. This helps if you simply update the wp_options table or wp_posts/wp_postmeta. The only downside is that currently you need to run it through a browser in the WP admin, but they are potentially working on a command line solution. They also have a beta add-on for keeping media files in sync, due out in the main plugin soon.
The next best option is to set up wp-cli. This allows you to run WordPress commands via the command line, and you can hook in and create your own. It has a built in search-replace function to update URLs & serialized data (it actually used the interconnectit search-and-replace mentioned elsewhere here). What I do to prepare the database is to use the search-replace function to update the URLs, export it via wp-cli, and then take that dump.sql and import it into the target database somehow. Easiest is via phpMyAdmin or Sequel Pro. OR, I have also written simple scripts that SCP the dump to the server and then import it via mysql command line.
Use interconnectit search-and-replace in your project. This has a browser base or CLI option. Iāve used the CLI as a part of a custom deploy bash script.
Use WP Engine. They have a push button production to/from staging setup which also allows for full or table-based db migration. Downside is that you still need to do one of the other options above for deployment to/from local. And, if you want to do any of the great Capistrano kind of stuff mentioned in this post, you are out of luck with WP Engine since they do not allow SSH access.
Hey merchantguru,
Wish I read this post before i posted to the capistrano screencast thread.
I too am looking to solve the database issue.
Option 2 sounds like the best plan, although i just use sed for find and replace, works a treat.
For all the love (or addiction) I have for Railsless Capistrano it always seemed wrong. Better to stand on the shoulders of giants: http://tech.toptable.co.uk/blog/2013/08/08/grunt-your-deployments-too/
I realize Iām super late to the game on this but just thought youād find it interesting. Iāll be giving this a whirl in an upcoming Roots site.
Keep in mind that Capistrano v3 was rewritten and no longer has anything Rails specific in it. You actually need to require Rails gems for it if you want. v3 is generally must better, simpler, and faster.
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