introduction to drush - drupalcamp london 2014

45
Introduction to Drush $ @anthonyalbertyn $ #dclondon $ z

Upload: anthony-albertyn

Post on 17-May-2015

882 views

Category:

Technology


0 download

DESCRIPTION

Presentation at DrupalCamp London 2014 about using Drush, the Drupal shell. Audio/video available here: http://youtu.be/XB4of9ev4Ts

TRANSCRIPT

Page 1: Introduction to Drush - DrupalCamp London 2014

Introduction to Drush$ @anthonyalbertyn$ #dclondon$ z

Page 2: Introduction to Drush - DrupalCamp London 2014

What is Drush? Drush = Drupal Shell Command line interface Scripting environment that can be

extended Toolbox of useful utilities

Page 3: Introduction to Drush - DrupalCamp London 2014

Why use Drush? Can be massively more productive

than using a GUI Access drush commands supplied

by contrib modules

Page 4: Introduction to Drush - DrupalCamp London 2014

What can Drush do? Perform tasks with modules, themes,

profiles, translations and core:- download, enable, update, - disable and uninstall

Add, remove and manage users

Page 5: Introduction to Drush - DrupalCamp London 2014

What else can Drush do? Various admin tasks like

clear cache, run cron, re-index search Database related tasks like

backup database, migrate databases between different sites

Page 6: Introduction to Drush - DrupalCamp London 2014

What do we need touse Drush locally ?

Install Drush on your pc/mac Terminal / Windows Command

Processor (command prompt)

Page 7: Introduction to Drush - DrupalCamp London 2014

What do we need touse Drush remotely ? Install Drush on server SSH client

- for Mac use Terminal- for Windows install and use PuTTY

Page 8: Introduction to Drush - DrupalCamp London 2014

Options for installing Drush Use PEAR (preferred way) Install Drush manually There are other ways too Instructions for various environments:

http://drupal.org/node/1791676

Page 9: Introduction to Drush - DrupalCamp London 2014

Two ways to use Drush Navigate to your Drupal root directory

on local or remote site and type:drush [command]

Setup a Drush site alias and locally from anywhere in Terminal type:drush @[alias] [command]

Page 10: Introduction to Drush - DrupalCamp London 2014

List useful Drush commands

drush help

Page 11: Introduction to Drush - DrupalCamp London 2014

Download modules

drush dl omega

drush dl date context ds

Page 12: Introduction to Drush - DrupalCamp London 2014

Enable modules

drush en omega

drush en date context ds

Page 13: Introduction to Drush - DrupalCamp London 2014

Disable modules

drush dis omega

drush dis date context ds

Page 14: Introduction to Drush - DrupalCamp London 2014

Uninstall modules

drush pm-uninstall omega

drush pm-uninstall date ds

Page 15: Introduction to Drush - DrupalCamp London 2014

List modules and themes on site

drush pm-list

Page 16: Introduction to Drush - DrupalCamp London 2014

More info on module in site

drush pm-info context

Page 17: Introduction to Drush - DrupalCamp London 2014

Clear the cache

drush cc

drush cc all

Page 18: Introduction to Drush - DrupalCamp London 2014

Run cron on your site

drush cron

Page 19: Introduction to Drush - DrupalCamp London 2014

Search status – how many items still need indexing

drush search-status

Page 20: Introduction to Drush - DrupalCamp London 2014

Search index – index remaining search items without wiping out the existing index

drush search-index

Page 21: Introduction to Drush - DrupalCamp London 2014

Search re-index – force the search index to be re-built

drush search-reindex

Page 22: Introduction to Drush - DrupalCamp London 2014

List available site aliases

drush sa

Page 23: Introduction to Drush - DrupalCamp London 2014

Show status of a site

drush status

drush @alias status

Page 24: Introduction to Drush - DrupalCamp London 2014

Get info about an existing user

drush user-information usernamedrush user-information useriddrush user-information useremail

Page 25: Introduction to Drush - DrupalCamp London 2014

Block and unblock a user

drush user-block username

drush user-unblock username

Page 26: Introduction to Drush - DrupalCamp London 2014

Create a new user

drush user-create username--mail=“[email protected]” --password=“password123”

Page 27: Introduction to Drush - DrupalCamp London 2014

Give a user a role

drush user-add-role ”user role” username

Page 28: Introduction to Drush - DrupalCamp London 2014

Set a new password for a user

drush user-password username --password=“newpass123”

Page 29: Introduction to Drush - DrupalCamp London 2014

One-time login link for a user

drush uli username

drush @alias uli username

Page 30: Introduction to Drush - DrupalCamp London 2014

Delete a user account

drush user-cancel username

Page 31: Introduction to Drush - DrupalCamp London 2014

Update drupal core and contrib modules to latest recommended releases and apply pending database updates

drush up

Page 32: Introduction to Drush - DrupalCamp London 2014

Dump database into sql file

drush sql-dump > /path/to/

myfile.sql

Page 33: Introduction to Drush - DrupalCamp London 2014

Copy entire database from one environment to another

drush sql-sync @site1 @site2

Page 34: Introduction to Drush - DrupalCamp London 2014

Sync files folder content from one site to another

drush rsync @site1:%files @site2:%files

Page 35: Introduction to Drush - DrupalCamp London 2014

More info on deploying sites

drush help site-aliasdrush help sql-sync drush help rsync

Page 36: Introduction to Drush - DrupalCamp London 2014

Setup and use Drush aliases Blog post about Drush aliases

http://www.astonishdesign.com/blog/drush-aliases-what-why-and-how

Synchronise and deploy siteshttp://drupal.org/node/670460

Example of valid alias statementshttp://drush.ws/examples/example.aliases.drushrc.php

Page 37: Introduction to Drush - DrupalCamp London 2014

Manual installation on Mac Download Drush from GitHub

http://github.com/drush-ops/drush Unpack into home directory

/Users/username Grant yourself file execution permissionschmod u+x /Users/username/drush/drush

Page 38: Introduction to Drush - DrupalCamp London 2014

Manual installation on Mac Tell OS X where to find Drush: Add drush path to your $PATH

- via Terminal- or Bash- or Profile

OR create a symbolic link to the path

Page 39: Introduction to Drush - DrupalCamp London 2014

Mac – add Drush to path Example:

In directory /Users/username,edit .profile and add:export PATH=$PATH:/Users/username/drush/drush

Page 40: Introduction to Drush - DrupalCamp London 2014

Mac – create symbolic link Example sym link:cd /usr/binln –s /Users/username/drush/drush

More info mac installation:http://drupal.org/node/1674222http://drupal.org/node/508450

Page 41: Introduction to Drush - DrupalCamp London 2014

Test that Drush works Open your Terminal and typedrush --version

To display a list of helpful drush commands:drush help

Page 42: Introduction to Drush - DrupalCamp London 2014

Learning resources Drush User’s Guide (book)

Novillo, J.P, Packt Publishing, 2012ISBN 978-1-84951-798-0

Drush for Humans – SANDcamp 2013Presenter: Jon Peckhttps://www.youtube.com/watch?v=Pp6UofwFMDw

Page 43: Introduction to Drush - DrupalCamp London 2014

Learning resources Drush optimizations for your

development workflow – DrupalCon Prague 2013Presenters: varioushttps://prague2013.drupal.org/session/drush-optimizations-your-development-workflow

Page 44: Introduction to Drush - DrupalCamp London 2014

Drush resources Drush commands

http://www.drush.org

Drush GitHub projecthttp://github.com/drush-ops/drush

Drush Windows installerhttp://drush.ws/drush_windows_installer

Drush API docshttp://api.drush.ws

Page 45: Introduction to Drush - DrupalCamp London 2014

About me @anthonyalbertyn Front-end web developer Co-founder and organiser of

#drupalcambs http://www.meetup.com/drupalcambs