Making use of Drush to save time as a Drupal Site Builder / Themer / Developer / DevOps
Drush can be one of the nicest tools to have, when you want to speed up quite a lot of your daily Drupal operations.
Here are some of the usages I've come across, for Drupal 7:
Clearing cache:
# clear all caches drush cc all # rebuild caches drush cr
Download and enable modules:
# download module modulename drush dl modulename # enable a downloaded module drush en modulename # to skip the Yes or No confirmation questions: drush -y en modulename
Downloading and enabling themes:
# download a theme drush dl themename # enabling a theme drush en themename # setting an enabled theme as default drush vset theme_default themename # setting an enabled theme as the admin theme drush vset admin_theme themename # list all installed themes drush pm-list --type=theme # show the current themes drush status theme
Generating dummy content and users using Devel module:
# Download and enable Devel module drush -y en devel # Enable Devel Generate submodule drush -y en devel_generate # Generate 50 random nodes, with up to 10 comments each drush generate-content 50 10 # Generate 20 random users drush generate-users 20
Export and Import databases:
# export DB to a backup file drush sql-dump > filename.sql # import DB from a backup file drush sql-cli < filename.sql # delete all data in your DB: drush sql-drop
Taking a full site backup:
# create a drush archive (code+files+DB) drush archive-dump
Importing and Exporting site configuration (using Features module):
# Assuming you use Features site wide for Content Types, Contexts, Views... # Revert all enabled features by overriding current DB config with the features code drush features-revert-all # Update all feature modules code based on your current DB config drush features-update-all
Running updates:
# run all available updates drush up
References:
1. https://evolvingweb.ca/blog/drush-commands-for-themers-and-site-builders
2. http://dropbucket.org/node/282
3. http://stackoverflow.com/questions/4727162/what-is-the-drush-command-to-...
4. https://drushcommands.com/drush-7x/
- 45981 reads
Add new comment