One-liner for fetching the live-database on your dev server (or localhost)
So when I first realised that I was neglecting this blog, I somewhat found comfort in that at least it hadn't been a year, right? OK, so now it has almost been a year. Does that mean I have stopped finding solutions to my Drupal problems (as the "About me" block states)? Well, no. The biggest problem is remembering to blog about them, or finding the time. But finding the time is not a Drupal problem, and I most definitely have not found the solution to that problem. Anyway, I digress. Let's end the streak with a quick tip that I use all the time: Syncing live databases without having drush aliases.
If you use drush-aliases, you could just do drush sql-sync. But for me, even if I do, I still prefer this method, as I find it extremely easy to debug.
First I make sure I am in my Drupal root:<br>$ cd /path/to/drupal<br>
Then I usually make sure I can bootstrap Drupal from drush:<br>$ drush st<br>
If that output says my database is connected, then let's test the remote connection:<br>$ ssh myuser@remotemachine.com "drush --root=/path/in/remote/server st"<br>
If that output also says we are connected, it means we are good to go, with my favourite command ever:<br>$ ssh myuser@remotemachine.com "drush --root=/path/in/remote/server sql-dump" | drush sql-cli<br>
If you have a drush-alias for the site, you can also go:<br>drush @live-site-alias sql-dump | drush sql-cli<br>
Tags: developmentdrushmysqldatabase dumpworkflowplanet drupal