User login

Use Drush to sync the database from one site to another

Based on Greg Anderson's chapter in the Definitive Guide to Drupal 7.

drush sql-sync @dgd7.prod @dgd7.local

Prerequisites

A dgd7.aliases.drushrc.php file in a ~/.drush directory (that's a .drush folder in your home directory) that contains something like:

<?php
$aliases
['prod'] = array(
 
'remote-host' => 'sojourner.mayfirst.org',
 
'remote-user' => 'definitivedrupal',
 
'root' => '/var/local/drupal/dgd7/drupal',
 
'uri' => 'definitivedrupal.org',
);
$aliases['test'] = array(
 
'remote-host' => 'simone.mayfirst.org',
 
'remote-user' => 'ben',
 
'root' => '/var/local/drupal/dgd7/drupal',
 
'uri' => 'dgd7.agariclabs.org',
);
$aliases['local'] = array(
 
'root' => '/home/ben/code/dgd7/drupal',
 
'uri' => 'dgd7.localhost',
);
?>

Note: The first time you do this, if you don't have a database locally already, you'll want to create one, as with drush si.

You can save a little transfer time by adding --structure-tables-key=common to the drush sql-sync command.

Searched words: 
drush pull down databases copy a database between drupal sites

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Syntax highlight code surrounded by the {syntaxhighlighter SPEC}...{/syntaxhighlighter} tags, where SPEC is a Syntaxhighlighter options string or "class="OPTIONS" title="the title".
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.