Django - The Easy Way Django - The Easy Way
Samuli Natri 2017.04.06
Samuli Natri is a software developer who enjoys programming games and web applications. He attended Helsinki University Of Technology (Computer Science) and Helsinki University (Social Sciences).

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


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


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


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


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


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