A command line shell for Drupal.
- https://www.drush.org
- Drush Commands
- Switching Drush Version
- Example Drush Alias YML file
- Drush Site Aliases
- Installing Drush 6 and 7 on Shared Hosting Accounts With Composer
-
Install a global version of Drush using Composer
composer global require drush/drush:dev-master
-
Shared Hosting
To make it easier to use, add an alias to your .bash_profile or .bashrc file:
alias drush='~/.composer/vendor/bin/drush'
Drush Launcher is basically a small wrapper that is triggered when you run drush. It looks if you're inside a Drupal project directory, then finds if there's a local version of Drush installed with the project. If so, it uses that version of Drush, configured for each Drupal project you work on.
- https://github.com/drush-ops/drush-launcher
- https://www.jeffgeerling.com/blog/2018/drupal-vm-48-and-drush-900-some-major-changes
For convenience, instead of passing the --fallback option any time you're using Drush outside a Composer-based Drupal project directory, you can set the environment variable DRUSH_LAUNCHER_FALLBACK, for example in your .bash_profile:
export DRUSH_LAUNCHER_FALLBACK=~/.composer/vendor/bin/drush
-
User Login
Display a one time login link for user ID 1, or another user. https://drushcommands.com/drush-9x/user/user:login/
$ drush uli
-
SQL-Sync
Copy DB data from a source site to a target site. Transfers data via rsync. https://drushcommands.com/drush-9x/sql/sql:sync/
drush sql-sync @source @target
-
SQL Dump
Exports the Drupal DB as SQL using mysqldump or equivalent. https://drushcommands.com/drush-9x/sql/sql:dump/
$ drush sql-dump --result-file=../PATH/"$(date +"%y%m%d%H%M%S")"-NAME.sql
-
SQL Import
Open a SQL command-line interface using Drupal's credentials. https://drushcommands.com/drush-9x/sql/sql:cli/
$ drush sqlc < PATH/TO/NAME.sql
-
Remote Sync
Rsync Drupal code or files to/from another server using ssh. https://drushcommands.com/drush-9x/core/core:rsync/
drush rsync @self:%files @target:%files # Flags --exclude=*.sql:file.ext:PATH/TO/DIRECTORY --delete