The core of Drush Rebuild revolves around the configuration file. Consider the
drush @example.local rebuild. In this command, Drush Rebuild is
going to rebuild the local development environment for
it is going to do so based on the tasks defined in the configuration file.
To start with, you should know that the rebuild config has three main sections:
general: description: 'Rebuilds local development environment from remote destination' uli: true overrides: 'local.rebuild.yaml' default_source: '@example.prod' drush_scripts: pre_process: ['example.php', 'another.php'] post_process: 'after_rebuild.php'
This key is self-explanatory. It is displayed to the user when
drush @example.local rebuild.
This key tells Drush to run
drush @example.local uli after completing
all the rebuild tasks. Set this to
false, or leave it out entirely, if you don’t
This key is used to specify the path to a local overrides
configuration file. For example, if your main configuration was at
/home/kosta/sites/example/resources/rebuild.yaml, your overrides would be at
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.
Drush Rebuild lets you rebuild your local environment based on any source
defined in your drush alias, so you could rebuild based on
@prod 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
@example.local rebuild instead of
drush @example.local rebuild --firstname.lastname@example.org.
This section tells Drush to run
php-script on the files specified in the
pre_process runs before any other step, while
comes at the very end. Note that returning
FALSE from a Drush script will
halt the rebuild process.
site_install section tells Drush that we are either using
site-install for rebuilding a local site. They are mutually
exclusive; you can’t have both in the same config.
This section lets you define options for syncing a remote database to your local environment.
sql_sync: create-db: 'TRUE' sanitize: sanitize-email structure-tables-key: common
If you just wanted database syncing without any additional options, you could write:
sync: sql_sync: true
Note that any option listed in
drush help sql-sync can be defined in your
rebuild config file.
If you are rebuilding by re-installing an install profile, you can set options like:
site_install: profile: 'standard' account-mail: 'admin@localhost' account-pass: 'admin' account-name: 'admin' site-name: 'Local install'
Any option listed in
drush help site-install can be defined in the config file.
Let’s take a look at the entire file now:
general: description: 'Rebuilds local development environment from remote destination' uli: true overrides: 'local.rebuild.yaml' drush_scripts: pre_process: ['example.php', 'another.php'] post_process: 'after_rebuild.php' sync: default_source: '@example.prod' sql_sync: create-db: 'TRUE' sanitize: 'sanitize-email' structure-tables-key: 'common' rsync: files_only: 'TRUE' drupal: variables: set: preprocess_js: 0 preprocess_css: 0 modules: enable: - devel - devel_node_access - dblog - views_ui disable: - overlay - syslog uninstall: - google_analytics permissions: anonymous user: grant: - access devel information - switch users revoke: - search content authenticated user: grant: - access devel information revoke: - search content