This document discusses using Drush, a command line shell and scripting interface, for deploying and managing Drupal sites remotely. It describes how Drush can be used to download, enable, and disable modules; manage users; clear caches; and set variables. Site aliases allow running Drush commands on remote servers by storing server details in alias files. The document then covers using Drush for common deployment tasks like syncing code and databases between environments. It also discusses writing custom Drush commands and how Drush looks up and loads commands.
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Dcp'14 drush
1. Using Drush as a Deployment
and remote Management tool
Piyuesh Kumar
Drupal Developer
QED42
2. Agenda
• What is Drush?
• Drush as a swiss army-knife for developers
• Drush site-aliases?
• Manage sites remotely using site-aliases?
• Write custom drush command to generate site-
aliases
3. What is Drush?
“Drush is a command-line shell and scripting interface
for Drupal, a veritable Swiss Army knife designed to
make life easier for those who spend their working
hours hacking away at the command prompt.”
6. Drush way of doing them
• drush dl/en/dis/pmu <module_name>
• drush ucrt/upwd/ublk/uublk
• drush cc/upc/updb/cron/ard/arr
• drush vset/vget/vdel <variable_name>
7. What are site-aliases?
“Drush aliases allow you to run a drush command on
your local server but actually execute the command on
a remote server.”
• Simple configuration files storing details about
various application instances/servers we want to
maintain using drush.
• Real time saver when working locally and then
you want to do something on the remote server
9. Site-aliases: How n where?
{
Filename: *.aliases.drushrc.php,
Location: [
{~/.drush},
{/etc/drush},
{drush installation folder/aliases}
]
}
• $options['alias-path'] in drushrc.php OR path passed in via —alias-path
11. Executing drush commands on a remote
instance
• drush @<site_alias> <drush command>
• e.g., drush @dev dl views && drush
@dev en -y views
12. Looks cool! But, i want to sanitise my
database while deploying it to any of the other
instances.
13. Advanced options
• —sanitize: resets emails and passwords for users
• Command-specific: Configure a command to execute in a specific
manner for a specific alias. e.g., to exclude couple of tables while
syncing up databases:
• source-command-specific/target-comment-specific: considers the
configuration while running a drush command for the source/target alias.
15. Code
• Deployable via git
• Use Capistrano/git hooks to deploy code
as per the need.
• http://guides.beanstalkapp.com/deployme
nts/deploy-with-capistrano.html
• http://www.sitepoint.com/one-click-app-
deployment-server-side-git-hooks/
16. Files
• drush rsync @<source alias> @<dest alias>
• —exclude=<pattern of filenames>
• —delete: deletes files that are not present on
the source.
17. Database Sync
• drush sql-sync @<source alias> @<dest alias>
• —create-db: create db if not exists
• —no-cache: exclude cache tables while syncing
up databases.
18. Irritated of your drush commands asking you for
passwords every time?
21. Where does drush lookup for commands?
• Filename: *.drush.inc
• location:
• ~/.drush/
• sites/all/drush inside current Drupal installation.
• Enabled modules in Current Drupal installation.
• /path to drush installation/commands/