Skip to content

Instantly share code, notes, and snippets.

@Paulmicha
Last active July 5, 2018 09:17
Show Gist options
  • Save Paulmicha/3945469 to your computer and use it in GitHub Desktop.
Save Paulmicha/3945469 to your computer and use it in GitHub Desktop.
Drush - usual commands cheatsheet
#!/bin/bash
# -*- coding: UTF8 -*-
##
# Drush usual commands cheat sheet
# Prerequisites : drush installed
#
# Sources:
# http://drushcommands.com/
# http://highrockmedia.com/blog/features-drush-drupal-goodness
# http://linuxdev.dk/blog/speed-drush-make
# http://www.lullabot.com/blog/article/module-monday-drush-search-replace
# http://www.undpaul.de/en/blog/2013/06/26/simplify-your-development-workflow-drush-and-scripts
# http://deeson-online.co.uk/labs/educating-drush
# http://deeson-online.co.uk/labs/drupal-drush-aliases-and-how-use-them
#
# Apply patch (requires module "drush_iq" installed - run "drush dl drush_iq" first)
# Note : seems not to work anymore since the conversion to git
drush iq-apply-patch http://drupal.org/node/1679392
# Cache clear all
drush cc all
# Cache clear css + js
drush cc css-js
#------------------------------------------------------------------------------------------
# Reset Drupal admin password
drush upwd admin --password="admin"
# Get an admin one-time login link
drush uli
#------------------------------------------------------------------------------------------
# Modules management
# Download & enable
# (auto-detects subdir "contrib" in modules directory when present)
drush dl token
drush en token -y
# Disable
drush dis token -y
# Upgrade a module (requires core module "update" enabled)
drush up token -y
# Upgrade everything (requires core module "update" enabled)
drush up -y
# Reinstall (requires module "devel" enabled)
drush devel-reinstall token -y
#------------------------------------------------------------------------------------------
# Features
# Export example (create new OR update a feature module)
# @see http://highrockmedia.com/blog/features-drush-drupal-goodness
drush fe events_feature views:latest_events
# Note : after exporting in a feature once, if you want to add stuff (re-export) in this same feature,
# it's mandatory to enable the feature first -- to carry on with our example :
drush en events_feature -y
# Build components list (the configuration available to features)
drush fc
drush fc --all
# Update a feature
# (write current site configuration into files)
drush fu events_feature -y
# Update all features
# (write current site configuration into files)
drush fua
# Revert a feature
# (replace current site configuration with the ones loaded from files)
drush fr events_feature
# Revert all features
# (replace current site configuration with the ones loaded from files)
drush fra
# List all features
drush fl
#------------------------------------------------------------------------------------------
# Variables
# List / find variables - ex. with pathauto :
drush vget | grep pathauto
#------------------------------------------------------------------------------------------
# Configuration
# Set variable value
drush vset maintenance_mode 0 --yes
# Delete variable
# ex: cron variables (useful when stuck)
drush vdel cron_semaphore
drush vdel cron_last
#------------------------------------------------------------------------------------------
# Localization update (l10n_update)
# Create / update cache
drush l10n-update-refresh
# Update translations
drush l10n-update -y
#------------------------------------------------------------------------------------------
# Solr
# Delete index
drush solr-delete-index
# Index
drush solr-index
#------------------------------------------------------------------------------------------
# Migration
# Status
drush ms
drush ms my_migration_name
# Recognize new migrations and update counts
drush ms --refresh
# Operations : Import / Update / Rollback & Import
drush mi --all
drush mi --group="my_group_name"
drush mi my_migration_name
# Ignore unmet dependencies
drush mi my_migration_name --force
drush mi my_migration_name --update
# Rollback before importing
drush mi my_migration_name --rollback
# Number of items to import
drush mi my_migration_name --limit="2"
# List (CSV) of source IDs to import
drush mi my_migration_name --idlist="123,124"
# Operations : Rollback
drush mr --all
drush mr my_migration_name
# Wipe : Delete all nodes from specified content types,
# with space delimited list of content type machine readable Ids as argument
drush mw content_type_name other_content_type_name
# Audit
drush ma my_migration_name
# Analyse
drush maz my_migration_name
# View messages
drush mmsg my_migration_name
# Mappings
drush mm my_migration_name
#------------------------------------------------------------------------------------------
# Devel
# Generate 12 users
drush genu 12
# Generate 25 nodes
drush genc 25
# Generate 25 nodes of type "book" and "page" only
drush genc 25 --types="book,page"
# Generate 25 nodes leaving out "field_my_test" and "field_foobar" fields (no values)
drush genc 25 --skip-fields="field_my_test,field_foobar"
# Generate 1 vocabulary (default qty is 1)
drush genv
# Generate 32 terms in "my_voc_name"
drush gent my_voc_name 32
# Generate menus
drush genm
#------------------------------------------------------------------------------------------
# Backup & migrate (requires module "backup_migrate" enabled)
# @see http://www.only10types.com/2011/03/drush-backup-and-migrate-command.html
# Create dump (default settings)
drush bb
# List manual dumps
drush bam-backups
# Restore manual dump
drush bam-restore db manual "Your.Site-01.01.2012-12.00.00.mysql.gz"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment