Last updated March 4, 2014. Created on March 21, 2013.
Edited by batigolix, kostajh. Log in to edit this page.


Type drush topic rebuild-example to see an example file.

A few things to note:

  1. The file is written using the INI syntax and follows the same conventions as a standard Drupal .info file.
  2. In general, "1" should be used to denote TRUE and "0" should be used to denote FALSE
  3. In most cases, options for different commands like sql-sync and rsync follow the same conventions as their drush counter parts. So when in doubt, type "drush help sql-sync" to find out what valid options you can use in the sql_sync section.

Rebuilding from a remote source

This example is valid for cases where you want to rebuild from a remote source.

; Sql-sync and rsync example.
; Enter a description of what your rebuild file does.
description = "Rebuilds local development environment from remote destination"

The description key lets you add a string that will be displayed to users who rebuild their local environment using the rebuild file. The description is optional.

; Optional - specify a version of your rebuild script
version = 1.0

The version key lets you specify a version of your info file. Useful for debugging with co-workers.

; Define the default source for a sql-sync. Not valid for site-install rebuild.
default_source =

Drush Rebuild lets you rebuild your local environment based on any source defined in your drush alias, so you could rebuild based on @staging, @qa, or @production aliases for example. But more often than not, you want your local development environment to match one remote environment. By defining default_source you can save yourself some typing. You'll be able to run drush rebuild @example.local instead of drush rebuild @example.local

; Define options for database sync
sql_sync[create-db] = TRUE
sql_sync[sanitize] = sanitize-email
sql_sync[structure-tables-key] = common

The sql_sync section lets you define options for syncing a remote database to your local environment. If you just wanted database syncing without any additional options, you could write:

sql_sync = 1

; Define options for rsync
; Either specify rsync[files_only] = 1, or define a list of rsync options
; to pass to drush.
rsync[files_only] = 1
; rsync[exclude] = .htaccess

As of Drush Rebuild version 1.2, rsync is not fully supported. But the option above (files_only) works just fine. This will rsync the files from your remote environment (what is in sites/default/files) to your local environment. Use with caution for large sites.

In the future, all the options supported by drush rsync will be supported by Drush Rebuild.

; Define variables to be set
variables[preprocess_js] = 0
variables[preprocess_css] = 0
; Note that %email will load the variable specified in your drush alias
; under array('rebuild' => 'email')
variables[reroute_email_address] = %email

The variables section is pretty straightforward - use the name of the variable and assign it a value.

In the code above, note that you can use placeholders. This requires a correctly configured Drush alias.

; Specify if user should be logged in after running rebuild
uli = 1

If the value is set to 1, Drush Rebuild will open your browser and log you into the site after the rebuild completes successfully. Set to 0, or don't include this in your file, if you don't want that behavior.

; Modules to enable
modules_enable[] = devel
modules_enable[] = devel_node_access
; Modules to disable
modules_disable[] = overlay

Define modules that you want to enable or disable.

; Specify any PHP scripts that should be executed during the rebuild process.
; The scripts will be executed using drush php-eval. pre_process files will be
; evaluated before drush rebuild does anything; post_process will be evaluated
; at the end of the rebuild process. The files must be in the same directory
; as your file.
pre_process = example.php
post_process = after_rebuild.php

This section is also straightforward. Note that if your pre_process or post_process script returns FALSE, the rebuild will halt.

; Specify the name of the file that contains any rebuild overrides.
; Provide the name of the file if it is in the same directory as,
; or the full path to the file otherwise.
overrides =

This is useful when a team is using the same rebuild file. You can define a local overrides file, and exclude it from version control, so that each team member can customize the rebuild process to their liking.

Rebuilding with an install profile

Everything from the above applies except for the sql_sync and rsync sections. In place of that, you will want this:

site_install[profile] = minimal
site_install[account-mail] = %email
site_install[account-name] = SuperAdmin
site_install[site-name] = Local Install

Note that the placeholder refers to a value defined in the rebuild section of your Drush alias.

Looking for support? Visit the forums, or join #drupal-support in IRC.