WDTUTORIALS

Drupal 8 - Useful Drush Commands

Selection of useful Drush commands for Drupal 8.

System And Files

Name Description
Backup site database into a folder ~/db_dumps (sql-dump ) drush sql-dump > ~/db_dumps/MYSITEBACKUP.sql
Import database (sql-cli) drush sqlc < ~/db_dumps/MYSITEBACKUP.sql
Flush caches and backup site database into a folder ~/db_dumps archiving the packet with gzip and using the current date in the filename drush cr && drush sql-dump | gzip -9 > ~/db_dumps/MYSITEBACKUP-$(date +%Y-%m-%d-%H.%M.%S).sql.gz
Import gz archived dump unzip < ~/db_dumps/MYSITEBACKUP.sql.gz | drush sqlc
Create archive (backup database, files and code). Stored by default in ~/drush-backups (archive-dump) drush ard
Restore archive (archive-restore) drush arr ARCHIVEFILE.tar.gz

Caches

Name Description
Rebuild and clear caches (cache-rebuild) drush cr
Clear a specific cache (or all) (cache-clear) drush cc
Clear CSS & JS drush cc css-js

Configuration

Name Description
List configuration names (config-list) drush cli
Export configuration (config-export) drush cex
Import configuration (config-import) drush cim

Devel

Note: these require the Devel module.

Name Description
Generate nodes (10 nodes with maximum of 5 comments) (generate-content) drush genc 10 5
Generate menus (2 menus with 2 links) (generate-menus) drush genm 2 2
Generate terms (2 terms for tags vocabulary) (generate-terms) drush gent tags 2
Generate users (10 users) (generate-users) drush genu 10
Generate vocabularies (2 vocabularies) (generate-vocabs) drush genv 2

Download and Installation

Name Description
Download and install one module (pm-enable) drush -y en devel
Download and install multiple modules (run twice) drush -y en admin_toolbar admin_toolbar_tools fpa coffee
Download admin_toolbar module to the /modules folder (pm-download) drush dl admin_toolbar
Download latest stable Drupal to a folder mysite drush dl drupal --drupal-project-rename=mysite
Download latest stable Drupal 7 to a folder mysite drush dl drupal-7 --drupal-project-rename=mysite
Install Drupal using standard profile (site-install) drush si standard --db-url='mysql://root:root@localhost/MYDATABASE' --site-name=MYSITENAME --account-name=admin --account-pass=admin

Miscellaneous

Name Description
Get temporary login url (user-login) drush uli
Show Drush version drush version

Updates

Name Description
Update database (RUN THIS AFTER UPDATES) (updatedb) drush updb
Update core (pm-update) drush up drupal
Update a module drush up admin_toolbar
Update all modules EXCEPT core (pm-updatecode) drush upc --no-core
Update all modules AND core drush upc

Samuli Natri built his first website in the late 90’s. He is very passionate about web technologies. He attended Helsinki University Of Technology (Computer Science) and Helsinki University (Social Sciences). He is the founder of WDTutorials.com.

Featured Python Tutorial For Beginners - Essentials In 1 Hour

Copyright @ 2018 WDTutorials.com. All rights reserved. Privacy policy.Terms Of Service.