Brush has been retired in favor of Bee. However, considering Brush has all features that pre-Composer era Drush did, which are still missing in Bee, and some users might still be using Brush, please note of the following facts:
Brush is a command line shell and Unix scripting interface for Backdrop CMS. Brush core ships with lots of useful commands for interacting with code like modules/themes/profiles. Similarly, it runs update.php, executes sql queries and DB migrations, and misc utilities like run cron or clear cache.
Brush is build on top of completely refactored pre-Symfony, pre-Composer Drupal era Drush, namely version 4.6.0. As alternatives to Brush, you may like to consider using:
While each alternative has a limited list of commands working, almost all Drush commands work on Brush except just a few ones. To see the full list of avalable commands, install Brush and open the help.html
file locally on your browser.
Read https://forum.backdropcms.org/forum/drop-command-line-shell-and-unix-scripting-interface-backdrop-cms for the detailed information on three projects.
For Linux/Unix/Mac:
Clone the Brush repository into a folder outside of your web site. For example:
cd /usr/local/src &&
sudo git clone https://github.com/backdrop-contrib/brush.git
To ease the use of brush,
sudo ln -s /usr/local/src/brush/brush /usr/local/bin
OR
add the folder that contains brush to your PATH
PATH=$PATH:/usr/local/src/brush
This goes into .profile, .bash_aliases or .bashrc in your home folder. NOTE: You must log out and then log back in again or re-load your bash configuration file to apply your changes to your current session:
source .bashrc
NOTE ON PHP.INI FILES
brush status
Start using brush by running brush
from your Backdrop root directory.
For Windows:
To see colorized command line outputs, it's recommended to install Console_Color2 by running either:
pear install Console_Color2
or
php pyrus.phar install pear/Console_Color2
Once installed and setup, you can use brush as follows while in any Backdrop directory:
brush [options] <command> [argument1] [argument2]
Use the 'help' command to get a list of available options and commands:
brush help
For even more documentation, use the 'topic' command:
brush topic
For multisite installations, you might need to use the -l or other command line options just to get brush to work:
brush -l http://example.com help
Related Options:
-r
NOTE: If you do not specify a URI with -l and brush falls back to the default site configuration, Backdrop's $GLOBAL['base_url'] will be set to http://default. This may cause some functionality to not work as expected.
The brush core-cli command provide a customized bash shell or lets you enhance your usual shell with its --pipe option.
Many commands support a --pipe option which returns machine readable output. See
brush pm-list --status=enabled --pipe
as an example.
Very intensive scripts can exhaust your available PHP memory. One remedy is to just restart automatically using bash. For example:
while true; do brush search-index; sleep 5; done
Inside the "examples" folder you will find some example files to help you get started with your brush configuration file (example.brushrc.php), site alias definitions (example.aliases.brushrc.php) and brush commands (sandwich.brush.inc). You will also see an example 'policy' file which can be customized to block certain commands or arguments as your organization needs.
If you get tired of typing options all the time, you can add them to your brush.php alias or create a brushrc.php file. These provide additional options for your brush call. They provide great flexibility for a multi-site installation, for example. See example.brushrc.php.
Brush lets you run commands on a remote server, or even on a set of remote servers. See example.aliases.brushrc.php for more information.
Brush ships with a number of commands, but you can easily write your own. In fact, writing a brush command is no harder than writing simple Backdrop modules, since brush command files closely follow the structure of ordinary Backdrop modules.
See sandwich.brush.inc for light details on the internals of a brush command file. Otherwise, the core commands in brush are good models for your own commands.
You can put your brush command file in a number of places:
brush topic docs-configuration
).In any case, it is important that you end the filename with ".brush.inc", so that brush can find it.
Bugs and Feature requests should be reported in the Issue Queue: https://github.com/backdrop-contrib/brush/issues
Originally developed by Arto Bendiken http://bendiken.net/ for Drupal 4.7, redesigned by Franz Heinzmann http://unbiskant.org/ in May 2007 for Drupal 5, maintained by Moshe Weitzman http://drupal.org/moshe with help from the folks listed at https://github.com/orgs/drush-ops/people.
Ported to Backdrop CMS as Drop by Alan Mels https://github.com/alanmels in October 2019, renamed as Brush in January 2020.
This project is GPL v3 software. See the LICENSE.txt file in this directory for complete text.