Drush
Jump to navigation
Jump to search
General
Drush is a command line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those of us who spend some of our working hours hacking away at the command prompt.
Installation
pear channel-discover pear.drush.org pear install drush/drush
Commands
I have dr
as an alias for drush
.
drush help alll the commands! drush help --filter choose which help category to echo
drush cc all clear cache
drush pml list installed and enabled modules drush dl [project] download project drush dl sasson-7.x-3.x-dev download sasson dev release drush updb run upgrade.php
drush en [project] -y enable project without confirmation drush dis [project] -y disable project drush pm-uninstall [project] remove project from db
drush sql-cli < example.sql
drush php-eval 'echo drush_get_context("DRUSH_DRUPAL_ROOT");' drush php-eval 'echo drush_locate_root() . "/" . drupal_get_path('theme', 'sasson');' drush eval 'echo theme_get_setting('sasson_compiler') . "\n" ;' otherwise gives trailing issue?
drush vset --yes site_offline_message "This site is being maintained"; drush vset --yes site_offline 1;
In Drupal 7 to simply put the site into maintenance mode:
drush vset --yes maintenance_mode 1;
drush user-login ryan displays a one-time login link for the user ryan. open `drush user-login ryan` open said link in browser dr uli
Site aliases
Drush uses site alias files to store context data. (Aegir still uses Drush 4)
drush help site-alias
Copy to ~/.drush, rename aliases.drushrc.php or further.
drush ev 'print_r(array_keys(drush_sitealias_get_record("@server_master")))' drush ev '$a = drush_sitealias_get_record("@gk.dev"); print_r($a["path-aliases"]);'
- http://api.drush.ws/api/drush/commands!sql!sync.sql.inc/function/drush_sql_sync/4.x
- http://api.drush.ws/api/drush/includes%21sitealias.inc/function/drush_sitealias_get_record/4.x
Deployment
To sort with Aegir#Remote
- drupal.org: Using drush to synchronize and deploy sites
drush help rsync drush help sql-sync
- http://www.prometsource.com/blog/using-sql-sync-rsync-drush
- vimeo: Synchronising drupal sites from local to remote using drush site aliases
- youtube: Drush Tip: Use sql-sync to Quickly Move a Database
- http://drupalcode.org/project/drush.git/blob/HEAD:/examples/sync_enable.drush.inc
- http://drupalcode.org/project/drush.git/blob/HEAD:/examples/sync_via_http.drush.inc
Site build
See Profiles
Two make files; mysite.build and mysite.make.
mysite.build is brief:
core = 7.x api = 2 projects[drupal][type] = "core" ; Our distribution projects[mysite][type] = "profile" projects[mysite][download][type] = "git" projects[mysite][download][url] = "git@gitserver.com:mysite.git" projects[mysite][download][branch] = "develop"
mysite.make contains the list of modules, themes, and libraries to download and add to the site.
Extras
- Drupal Audit - This shell script allows a quick "audit" of a website, giving some details about the configuration: drush status, hacked status (using Hacked module), modules & themes status, cache status (using Cacheaudit module), database volumetry indications, phpinfo() ...
- Drush Rebuild is a utility for rebuilding your local development environments, using your existing Drush aliases and an easy-to-read config file.
drush rebuild @example.local --source=@example.prod Rebuild the environment at `@example.local using the source `@example.prod` drush rebuild @example.local --view-config View the config for rebuilding `@example.local`. Does not execute any tasks. drush rebuild-info @example.local Displays statistics on rebuilds for `@example.local`
- dman's sandbox: Drush sync scripts - This dirty cluster of scripts has followed me around through a dozen servers now, sometimes living in private CVS, sometimes in the old Drupal sandbox.
- Drush UI - An experiment to stick an ncurses/Dialog interface ontop of Drush. This project is not to be taken seriously and use of it is actually discouraged.
Provision
See Aegir
- Drush Seed - Seed is a heavy-weight script for the mangement of Ubuntu based Drupal development servers. It gives users Drush-based access and management to server-level functionality such as: User accounts and SSH keys, MySQL users and databases, Drupal installs (known in Seed as projects) and aliases, Apache virtual hosts
- Drush Vagrant provides Drush commands to accomplish common Vagrant tasks, and provides a powerful templating framework ('blueprints'). It also has tools to implement Drush aliases for Vagrant projects and VMs, thus allowing simpler remote control of Vagrant projects.