SlideShare ist ein Scribd-Unternehmen logo
1 von 31
Downloaden Sie, um offline zu lesen
A Drush Primer
DrupalCamp Chattanooga 2013
Chris Hales
DevOps Manager
Twitter: @chris_hales
IRC: chales
@Mediacurrent

Not on the Agenda
●
●
●
●

General Drupal administration
How to use the terminal
How to install Drush (RTFM)
Really deep dive examples (well, just a few)
@Mediacurrent

Agenda
●
●
●
●
●
●
●
●

What is Drush?
Some history
Basic use
Simple commands to make your life easier
Drush aliases
Advanced commands
Custom combinations
Drush Make
Drush
Well over 889,000 downloads
Integration with 276+ modules
Packages available for most systems
What is

Drush?
“A command line shell and
scripting interface for
Drupal.”
www.drush.org
@Mediacurrent

What is it?
The main focus of Drush is to take complex commands that you could
perform within the terminal and shorten them into simplified and easy to
remember commands.
rsync -vldkogDtprz ssh root@192.168.1.128:
/var/www/drupal/sites/default/files
/local/www/drupal/sites/default/files
Or if you use Drush with an alias setup for your dev site you can use the
following command.
$ drush rsync @mysite.dev:%files @mysite.local:%files
@Mediacurrent

History
Drush is a command line utility to assist in Drupal site building,
maintenance and administration tasks.
It is a Drupal contrib project but it’s not a module. On *nix systems it’s run
as a shell script or a bat on Windows. The guts are written in PHP so most
Drupal developers should understand the inner workings.
The first commit to the project was made on Nov 12, 2006 by Arto
Bendiken. He made the first few commits that started the 4.x release.
Drupal legend Moshe Weitzman has been the
primary maintainer for the past few years but
he’s had a lot of help. At this time there are
165 contributors to the project.
@Mediacurrent

History
The current version of Drush is version 7 which is compatible with
Drupal 6, 7 and 8.
The Drush project moved to Github in August 2013 however you can still
find general info on the original Drupal hosted project page.
http://drupal.org/project/drush
Look for Drush at it’s new home on Github
https://github.com/drush-ops/drush
The

Basics
@Mediacurrent

Getting Help
Review the Drush documentation online
http://www.drush.org/help/docs
Resources on Drupal.org
https://drupal.org/node/477684
https://drupal.org/drush-faq
http://www.drush.org/resources
https://groups.drupal.org/node/28088
Drush itself has a very extensive help system
$ drush --help
$ drush help <command>

And don’t forget Google
is your friend!
@Mediacurrent

The Basics
To use Drush with remote hosts you must use SSH keys!
Drush can perform some commands against remote sites without the
need for Drush to be installed on the remote.
You must be within the context of a fully functional Drupal site to use
most commands. For multisites drill into the site directory with the
settings.php file of the site you wish to work with. If you see the
following error you are not within a functional site.
Command <command> needs a higher bootstrap level to run - you
will need to invoke drush from a more functional Drupal
environment to run this command.
[error]
A Drupal installation directory could not be found
@Mediacurrent

Commands
The main command structure usually looks like this.
$ drush <cmd> [[arg1] [arg2]...] [[option1] [option2]...]
Drush commands are usually in the form of
$ drush <command> <from site> <to site>
Common options that remove interaction.
-y(es) -n(o)
$ drush <command> <from site> <to site> -y
@Mediacurrent

Common Tasks
Here are a few of the common admin tasks.

●
●
●
●
●
●
●

Clear caches
Install modules
Update modules
Run update.php
Update configuration settings
Manual cron runs
Updating users
@Mediacurrent

Site Status
Check your site status.
$ cd /path/to/drupal/docroot
$ drush st
Drupal version
Site URI
Database driver
Database username
Database password
Database name
Database
Drupal bootstrap
Drupal user

:
:
:
:
:
:
:
:
:

6.28
mysite.dev
mysqli
user
pass
ag_www
Connected
Successful
Anonymous
@Mediacurrent

Site Status
Default theme
: mytheme
Administration theme : seven
Administration theme : seven
PHP executable
: /path/to/php
PHP configuration
: /path/to/conf/php.ini
PHP OS
: Darwin
Drush version
: 6.0
Drush configuration : "/path/to/drush/drushrc.php"
Drush alias files
: ~/.drush/my.drushrc.php
Drupal root
: /path/to/docroot
Site path
: sites/mysite.dev
File directory path : sites/default/files
Temporary file directory path
: /tmp
@Mediacurrent

Clearing Cache
Clearing caches.
$ cd /path/to/drupal/docroot
$ drush cc
Enter a number to choose which cache to clear.
[0]
: Cancel
[1]
: all
[2]
: drush
[3]
: theme-registry
[4]
: menu
[5]
: css-js
[6]
: block
[7]
: module-list
[8]
: theme-list
[9]
: registry
[10] : views
@Mediacurrent

Clearing Cache
Clear all caches.
$ cd /path/to/drupal/docroot
$ drush cc all
'all' cache was cleared in mysite.local [success]
Clear just a specific cache such as the CSS/JS cache
$ cd /path/to/drupal/docroot
$ drush cc css-js
'css-js' cache was cleared in mysite.local [success]
@Mediacurrent

Install Modules
Download the module.
$ cd /path/to/drupal/docroot
$ drush dl schema
Project schema (6.x-1.7) downloaded to
sites/all/modules/contrib/schema.
[success]
Then enable the module.
$ drush en schema
schema was enabled successfully.
You can also combine the commands.
$ drush dl scheme && drush en schema -y

[ok]
@Mediacurrent

Update Modules
View a list of available module updates.
(output abbreviated)
$ cd /path/to/drupal/docroot
$ drush up
Name
context
ctools
features
filefield

Installed Version
6.x-3.1
6.x-1.10+2-dev
6.x-1.x-dev
6.x-3.10

Proposed version Message
6.x-3.3
SECURITY UPDATE available
6.x-1.0
Update available
6.x-1.2
Update available
6.x-3.11
Update available

Do you really want to continue with the update process? (y/n):
@Mediacurrent

Update Modules
Update one or more modules by specifying them. The new version will be
downloaded, any database updates executed and caches cleared.
(output abbreviated)
$ cd /path/to/drupal/docroot
$ drush up context features
Do you really want to continue with the update process? (y/n): y
Project context was updated successfully. Installed version is
now 6.x-3.3.
Backups were saved into the directory /backups/context. [ok]
'all' cache was cleared in mysite.local
[success]
No database updates required
[success]
'all' cache was cleared in mysite.local
[success]
Finished performing updates.
[ok]
Advanced
@Mediacurrent

Drush Aliases
Drush aliases allow your to target the context of a site much easier.
$ cd /path/to/drupal/docroot
$ drush sa --full --with-optional @self
$aliases["self"] = array (
'root' => '/path/to/site/docroot',
'uri' => 'http://default',
'#name' => 'self',
'path-aliases' =>
array (
'%drush' => '/path/to/php/drush',
'%site' => 'sites/default/',
),
);
@Mediacurrent

Drush Aliases
Once you create an alias file and name the sites you wish to interact with
you can target the sites’ context and run any command against it.
For a full featured alais template you can use mine as a starting point,
https://gist.github.com/chales/2635760
Download a module to the local site.
$ drush @mysite.local dl admin_menu
Check production status.
$ drush @mysite.prod st
Clear caches on the staging site.
$ drush @mysite.stage cc all
@Mediacurrent

Drush Aliases
Now you can use alias shortcuts to perform commands such as syncing
your local site to the production site.
Sync the files in sites/default/files using the files path alias.
$ drush rsync @mysite.prod:%files @mysite.local:%files
Sync the database using sql-sync.
$ drush sql-sync @mysite.prod @mysite.local
@Mediacurrent

Database Dumps
Backup a database.
$ drush sql-dump --result-file=dump.sql
Backup a database using gzip compression.
$ drush sql-dump --gzip --result-file=dump.sql.gz
Similar but you can just use the command output and write it to a file.
$ drush sql-dump > /path/to/dump/file.sql
To restore this dump file you can use the Drush sql-query command.
$ drush sqlq < /path/to/dump/file.sql
@Mediacurrent

Site Install
You can install a full Drupal site.
$ cd /path/to/drupal/docroot
$ drush si --db-url=mysql://root:root@127.0.0.1/test_d7
--account-pass=abc123
(assumes you have a database setup already)
If you need to add the database you can also use the superuser options
which will then create the database as well.
--db-su=name --db-su-pw=password --accountpass=myadminpass
@Mediacurrent

Variables
List all available variables.
$ drush variable-get
Set maintenance mode.
$ drush variable-set maintenance_mode 1
maintenance_mode was set to "1".
[success]
Disable maintenance mode.
$ drush variable-set maintenance_mode 0
maintenance_mode was set to "0".
[success]
Thank You!

Questions?
@chris_hales

Mediacurrent.com

slideshare.net/chris_hales

Weitere ähnliche Inhalte

Was ist angesagt?

Drupal and Security: What You Need to Know
Drupal and Security: What You Need to KnowDrupal and Security: What You Need to Know
Drupal and Security: What You Need to KnowAcquia
 
Apache Hadoop & Hive installation with movie rating exercise
Apache Hadoop & Hive installation with movie rating exerciseApache Hadoop & Hive installation with movie rating exercise
Apache Hadoop & Hive installation with movie rating exerciseShiva Rama Krishna Dasharathi
 
Hadoop Installation
Hadoop InstallationHadoop Installation
Hadoop InstallationAhmed Salman
 
Java Security Manager Reloaded - jOpenSpace Lightning Talk
Java Security Manager Reloaded - jOpenSpace Lightning TalkJava Security Manager Reloaded - jOpenSpace Lightning Talk
Java Security Manager Reloaded - jOpenSpace Lightning TalkJosef Cacek
 
Tips on Securing Drupal Sites
Tips on Securing Drupal SitesTips on Securing Drupal Sites
Tips on Securing Drupal Sitescgmonroe
 
Java Security Manager Reloaded - Devoxx 2014
Java Security Manager Reloaded - Devoxx 2014Java Security Manager Reloaded - Devoxx 2014
Java Security Manager Reloaded - Devoxx 2014Josef Cacek
 
Drupal Security Intro
Drupal Security IntroDrupal Security Intro
Drupal Security IntroCash Williams
 
Drupal campleuven: Secure Drupal Development
Drupal campleuven: Secure Drupal DevelopmentDrupal campleuven: Secure Drupal Development
Drupal campleuven: Secure Drupal DevelopmentSteven Van den Hout
 
Drupal security
Drupal securityDrupal security
Drupal securityJozef Toth
 
Two scoops of Django - Security Best Practices
Two scoops of Django - Security Best PracticesTwo scoops of Django - Security Best Practices
Two scoops of Django - Security Best PracticesSpin Lai
 
Attacking Oracle with the Metasploit Framework
Attacking Oracle with the Metasploit FrameworkAttacking Oracle with the Metasploit Framework
Attacking Oracle with the Metasploit FrameworkChris Gates
 
DevOps Fest 2019. Сергей Марченко. Terraform: a novel about modules, provider...
DevOps Fest 2019. Сергей Марченко. Terraform: a novel about modules, provider...DevOps Fest 2019. Сергей Марченко. Terraform: a novel about modules, provider...
DevOps Fest 2019. Сергей Марченко. Terraform: a novel about modules, provider...DevOps_Fest
 
I Have the Power(View)
I Have the Power(View)I Have the Power(View)
I Have the Power(View)Will Schroeder
 
Friends of Solr - Nutch & HDFS
Friends of Solr - Nutch & HDFSFriends of Solr - Nutch & HDFS
Friends of Solr - Nutch & HDFSSaumitra Srivastav
 

Was ist angesagt? (17)

Drupal and Security: What You Need to Know
Drupal and Security: What You Need to KnowDrupal and Security: What You Need to Know
Drupal and Security: What You Need to Know
 
Apache Hadoop & Hive installation with movie rating exercise
Apache Hadoop & Hive installation with movie rating exerciseApache Hadoop & Hive installation with movie rating exercise
Apache Hadoop & Hive installation with movie rating exercise
 
Secure your site
Secure your siteSecure your site
Secure your site
 
Hadoop Installation
Hadoop InstallationHadoop Installation
Hadoop Installation
 
Java Security Manager Reloaded - jOpenSpace Lightning Talk
Java Security Manager Reloaded - jOpenSpace Lightning TalkJava Security Manager Reloaded - jOpenSpace Lightning Talk
Java Security Manager Reloaded - jOpenSpace Lightning Talk
 
Tips on Securing Drupal Sites
Tips on Securing Drupal SitesTips on Securing Drupal Sites
Tips on Securing Drupal Sites
 
Java Security Manager Reloaded - Devoxx 2014
Java Security Manager Reloaded - Devoxx 2014Java Security Manager Reloaded - Devoxx 2014
Java Security Manager Reloaded - Devoxx 2014
 
Drupal Security Intro
Drupal Security IntroDrupal Security Intro
Drupal Security Intro
 
Secure Your Wordpress
Secure Your WordpressSecure Your Wordpress
Secure Your Wordpress
 
Drupal campleuven: Secure Drupal Development
Drupal campleuven: Secure Drupal DevelopmentDrupal campleuven: Secure Drupal Development
Drupal campleuven: Secure Drupal Development
 
Drupal security
Drupal securityDrupal security
Drupal security
 
Two scoops of Django - Security Best Practices
Two scoops of Django - Security Best PracticesTwo scoops of Django - Security Best Practices
Two scoops of Django - Security Best Practices
 
Attacking Oracle with the Metasploit Framework
Attacking Oracle with the Metasploit FrameworkAttacking Oracle with the Metasploit Framework
Attacking Oracle with the Metasploit Framework
 
DevOps Fest 2019. Сергей Марченко. Terraform: a novel about modules, provider...
DevOps Fest 2019. Сергей Марченко. Terraform: a novel about modules, provider...DevOps Fest 2019. Сергей Марченко. Terraform: a novel about modules, provider...
DevOps Fest 2019. Сергей Марченко. Terraform: a novel about modules, provider...
 
htaccess
htaccesshtaccess
htaccess
 
I Have the Power(View)
I Have the Power(View)I Have the Power(View)
I Have the Power(View)
 
Friends of Solr - Nutch & HDFS
Friends of Solr - Nutch & HDFSFriends of Solr - Nutch & HDFS
Friends of Solr - Nutch & HDFS
 

Ähnlich wie A Drush Primer - DrupalCamp Chattanooga 2013

Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011
Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011
Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011Vlad Savitsky
 
Drush for drupal website builder
Drush for drupal website builderDrush for drupal website builder
Drush for drupal website builderAdolfo Nasol
 
Face your fears: Drush and Aegir
Face your fears: Drush and AegirFace your fears: Drush and Aegir
Face your fears: Drush and AegirIztok Smolic
 
DrupalTour. Ternopil — Drupal shell or just Drush (Serhii Puchkovskii, Intern...
DrupalTour. Ternopil — Drupal shell or just Drush (Serhii Puchkovskii, Intern...DrupalTour. Ternopil — Drupal shell or just Drush (Serhii Puchkovskii, Intern...
DrupalTour. Ternopil — Drupal shell or just Drush (Serhii Puchkovskii, Intern...Drupaltour
 
Drush 5.0 (DrupalCamp LA 2012) - Chris Charlton
Drush 5.0 (DrupalCamp LA 2012) - Chris CharltonDrush 5.0 (DrupalCamp LA 2012) - Chris Charlton
Drush 5.0 (DrupalCamp LA 2012) - Chris CharltonChris Charlton
 
Drush to simplify Drupalers work - Sivaji
Drush to simplify Drupalers work - SivajiDrush to simplify Drupalers work - Sivaji
Drush to simplify Drupalers work - SivajiDrupal Camp Delhi
 
Drush Presentation
Drush PresentationDrush Presentation
Drush Presentationperceptum
 
Drush. Why should it be used?
Drush. Why should it be used?Drush. Why should it be used?
Drush. Why should it be used?Sergei Stryukov
 
Drush A beginners guide to a advanced tool.
Drush A beginners guide to a advanced tool.Drush A beginners guide to a advanced tool.
Drush A beginners guide to a advanced tool.Mediacurrent
 
drush_multi @ DrupalDevDays 2010
drush_multi @ DrupalDevDays 2010drush_multi @ DrupalDevDays 2010
drush_multi @ DrupalDevDays 2010Florian Latzel
 
Drupal on your laptop
Drupal on your laptopDrupal on your laptop
Drupal on your laptopSam Moore
 
Drush workshop
Drush workshopDrush workshop
Drush workshopJuampy NR
 
5 Important Tools for Drupal Development
5 Important Tools for Drupal Development5 Important Tools for Drupal Development
5 Important Tools for Drupal Developmentjcarrig
 
Drush and drupal. администрирование. Волчек Михаил
Drush and drupal. администрирование. Волчек МихаилDrush and drupal. администрирование. Волчек Михаил
Drush and drupal. администрирование. Волчек МихаилPVasili
 
Drush and drupal. администрирование волчек михаил
Drush and drupal. администрирование  волчек михаилDrush and drupal. администрирование  волчек михаил
Drush and drupal. администрирование волчек михаилdrupalconf
 
Improving your Drupal 8 development workflow DrupalCampLA
Improving your Drupal 8 development workflow DrupalCampLAImproving your Drupal 8 development workflow DrupalCampLA
Improving your Drupal 8 development workflow DrupalCampLAJesus Manuel Olivas
 
Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011
Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011
Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011camp_drupal_ua
 

Ähnlich wie A Drush Primer - DrupalCamp Chattanooga 2013 (20)

Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011
Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011
Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011
 
Drush for drupal website builder
Drush for drupal website builderDrush for drupal website builder
Drush for drupal website builder
 
Face your fears: Drush and Aegir
Face your fears: Drush and AegirFace your fears: Drush and Aegir
Face your fears: Drush and Aegir
 
DrupalTour. Ternopil — Drupal shell or just Drush (Serhii Puchkovskii, Intern...
DrupalTour. Ternopil — Drupal shell or just Drush (Serhii Puchkovskii, Intern...DrupalTour. Ternopil — Drupal shell or just Drush (Serhii Puchkovskii, Intern...
DrupalTour. Ternopil — Drupal shell or just Drush (Serhii Puchkovskii, Intern...
 
Drush 5.0 (DrupalCamp LA 2012) - Chris Charlton
Drush 5.0 (DrupalCamp LA 2012) - Chris CharltonDrush 5.0 (DrupalCamp LA 2012) - Chris Charlton
Drush 5.0 (DrupalCamp LA 2012) - Chris Charlton
 
Drush
DrushDrush
Drush
 
Drush to simplify Drupalers work - Sivaji
Drush to simplify Drupalers work - SivajiDrush to simplify Drupalers work - Sivaji
Drush to simplify Drupalers work - Sivaji
 
Drush Presentation
Drush PresentationDrush Presentation
Drush Presentation
 
Drush. Why should it be used?
Drush. Why should it be used?Drush. Why should it be used?
Drush. Why should it be used?
 
Dcp'14 drush
Dcp'14 drushDcp'14 drush
Dcp'14 drush
 
Drush A beginners guide to a advanced tool.
Drush A beginners guide to a advanced tool.Drush A beginners guide to a advanced tool.
Drush A beginners guide to a advanced tool.
 
drush_multi @ DrupalDevDays 2010
drush_multi @ DrupalDevDays 2010drush_multi @ DrupalDevDays 2010
drush_multi @ DrupalDevDays 2010
 
Drupal on your laptop
Drupal on your laptopDrupal on your laptop
Drupal on your laptop
 
Drush workshop
Drush workshopDrush workshop
Drush workshop
 
5 Important Tools for Drupal Development
5 Important Tools for Drupal Development5 Important Tools for Drupal Development
5 Important Tools for Drupal Development
 
Drush and drupal. администрирование. Волчек Михаил
Drush and drupal. администрирование. Волчек МихаилDrush and drupal. администрирование. Волчек Михаил
Drush and drupal. администрирование. Волчек Михаил
 
Drush and drupal. администрирование волчек михаил
Drush and drupal. администрирование  волчек михаилDrush and drupal. администрирование  волчек михаил
Drush and drupal. администрирование волчек михаил
 
Intro to Drush
Intro to DrushIntro to Drush
Intro to Drush
 
Improving your Drupal 8 development workflow DrupalCampLA
Improving your Drupal 8 development workflow DrupalCampLAImproving your Drupal 8 development workflow DrupalCampLA
Improving your Drupal 8 development workflow DrupalCampLA
 
Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011
Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011
Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011
 

Kürzlich hochgeladen

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 

Kürzlich hochgeladen (20)

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 

A Drush Primer - DrupalCamp Chattanooga 2013

  • 1. A Drush Primer DrupalCamp Chattanooga 2013
  • 2. Chris Hales DevOps Manager Twitter: @chris_hales IRC: chales
  • 3. @Mediacurrent Not on the Agenda ● ● ● ● General Drupal administration How to use the terminal How to install Drush (RTFM) Really deep dive examples (well, just a few)
  • 4. @Mediacurrent Agenda ● ● ● ● ● ● ● ● What is Drush? Some history Basic use Simple commands to make your life easier Drush aliases Advanced commands Custom combinations Drush Make
  • 5. Drush Well over 889,000 downloads Integration with 276+ modules Packages available for most systems
  • 7. “A command line shell and scripting interface for Drupal.” www.drush.org
  • 8. @Mediacurrent What is it? The main focus of Drush is to take complex commands that you could perform within the terminal and shorten them into simplified and easy to remember commands. rsync -vldkogDtprz ssh root@192.168.1.128: /var/www/drupal/sites/default/files /local/www/drupal/sites/default/files Or if you use Drush with an alias setup for your dev site you can use the following command. $ drush rsync @mysite.dev:%files @mysite.local:%files
  • 9. @Mediacurrent History Drush is a command line utility to assist in Drupal site building, maintenance and administration tasks. It is a Drupal contrib project but it’s not a module. On *nix systems it’s run as a shell script or a bat on Windows. The guts are written in PHP so most Drupal developers should understand the inner workings. The first commit to the project was made on Nov 12, 2006 by Arto Bendiken. He made the first few commits that started the 4.x release. Drupal legend Moshe Weitzman has been the primary maintainer for the past few years but he’s had a lot of help. At this time there are 165 contributors to the project.
  • 10. @Mediacurrent History The current version of Drush is version 7 which is compatible with Drupal 6, 7 and 8. The Drush project moved to Github in August 2013 however you can still find general info on the original Drupal hosted project page. http://drupal.org/project/drush Look for Drush at it’s new home on Github https://github.com/drush-ops/drush
  • 11.
  • 13. @Mediacurrent Getting Help Review the Drush documentation online http://www.drush.org/help/docs Resources on Drupal.org https://drupal.org/node/477684 https://drupal.org/drush-faq http://www.drush.org/resources https://groups.drupal.org/node/28088 Drush itself has a very extensive help system $ drush --help $ drush help <command> And don’t forget Google is your friend!
  • 14. @Mediacurrent The Basics To use Drush with remote hosts you must use SSH keys! Drush can perform some commands against remote sites without the need for Drush to be installed on the remote. You must be within the context of a fully functional Drupal site to use most commands. For multisites drill into the site directory with the settings.php file of the site you wish to work with. If you see the following error you are not within a functional site. Command <command> needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to run this command. [error] A Drupal installation directory could not be found
  • 15. @Mediacurrent Commands The main command structure usually looks like this. $ drush <cmd> [[arg1] [arg2]...] [[option1] [option2]...] Drush commands are usually in the form of $ drush <command> <from site> <to site> Common options that remove interaction. -y(es) -n(o) $ drush <command> <from site> <to site> -y
  • 16. @Mediacurrent Common Tasks Here are a few of the common admin tasks. ● ● ● ● ● ● ● Clear caches Install modules Update modules Run update.php Update configuration settings Manual cron runs Updating users
  • 17. @Mediacurrent Site Status Check your site status. $ cd /path/to/drupal/docroot $ drush st Drupal version Site URI Database driver Database username Database password Database name Database Drupal bootstrap Drupal user : : : : : : : : : 6.28 mysite.dev mysqli user pass ag_www Connected Successful Anonymous
  • 18. @Mediacurrent Site Status Default theme : mytheme Administration theme : seven Administration theme : seven PHP executable : /path/to/php PHP configuration : /path/to/conf/php.ini PHP OS : Darwin Drush version : 6.0 Drush configuration : "/path/to/drush/drushrc.php" Drush alias files : ~/.drush/my.drushrc.php Drupal root : /path/to/docroot Site path : sites/mysite.dev File directory path : sites/default/files Temporary file directory path : /tmp
  • 19. @Mediacurrent Clearing Cache Clearing caches. $ cd /path/to/drupal/docroot $ drush cc Enter a number to choose which cache to clear. [0] : Cancel [1] : all [2] : drush [3] : theme-registry [4] : menu [5] : css-js [6] : block [7] : module-list [8] : theme-list [9] : registry [10] : views
  • 20. @Mediacurrent Clearing Cache Clear all caches. $ cd /path/to/drupal/docroot $ drush cc all 'all' cache was cleared in mysite.local [success] Clear just a specific cache such as the CSS/JS cache $ cd /path/to/drupal/docroot $ drush cc css-js 'css-js' cache was cleared in mysite.local [success]
  • 21. @Mediacurrent Install Modules Download the module. $ cd /path/to/drupal/docroot $ drush dl schema Project schema (6.x-1.7) downloaded to sites/all/modules/contrib/schema. [success] Then enable the module. $ drush en schema schema was enabled successfully. You can also combine the commands. $ drush dl scheme && drush en schema -y [ok]
  • 22. @Mediacurrent Update Modules View a list of available module updates. (output abbreviated) $ cd /path/to/drupal/docroot $ drush up Name context ctools features filefield Installed Version 6.x-3.1 6.x-1.10+2-dev 6.x-1.x-dev 6.x-3.10 Proposed version Message 6.x-3.3 SECURITY UPDATE available 6.x-1.0 Update available 6.x-1.2 Update available 6.x-3.11 Update available Do you really want to continue with the update process? (y/n):
  • 23. @Mediacurrent Update Modules Update one or more modules by specifying them. The new version will be downloaded, any database updates executed and caches cleared. (output abbreviated) $ cd /path/to/drupal/docroot $ drush up context features Do you really want to continue with the update process? (y/n): y Project context was updated successfully. Installed version is now 6.x-3.3. Backups were saved into the directory /backups/context. [ok] 'all' cache was cleared in mysite.local [success] No database updates required [success] 'all' cache was cleared in mysite.local [success] Finished performing updates. [ok]
  • 25. @Mediacurrent Drush Aliases Drush aliases allow your to target the context of a site much easier. $ cd /path/to/drupal/docroot $ drush sa --full --with-optional @self $aliases["self"] = array ( 'root' => '/path/to/site/docroot', 'uri' => 'http://default', '#name' => 'self', 'path-aliases' => array ( '%drush' => '/path/to/php/drush', '%site' => 'sites/default/', ), );
  • 26. @Mediacurrent Drush Aliases Once you create an alias file and name the sites you wish to interact with you can target the sites’ context and run any command against it. For a full featured alais template you can use mine as a starting point, https://gist.github.com/chales/2635760 Download a module to the local site. $ drush @mysite.local dl admin_menu Check production status. $ drush @mysite.prod st Clear caches on the staging site. $ drush @mysite.stage cc all
  • 27. @Mediacurrent Drush Aliases Now you can use alias shortcuts to perform commands such as syncing your local site to the production site. Sync the files in sites/default/files using the files path alias. $ drush rsync @mysite.prod:%files @mysite.local:%files Sync the database using sql-sync. $ drush sql-sync @mysite.prod @mysite.local
  • 28. @Mediacurrent Database Dumps Backup a database. $ drush sql-dump --result-file=dump.sql Backup a database using gzip compression. $ drush sql-dump --gzip --result-file=dump.sql.gz Similar but you can just use the command output and write it to a file. $ drush sql-dump > /path/to/dump/file.sql To restore this dump file you can use the Drush sql-query command. $ drush sqlq < /path/to/dump/file.sql
  • 29. @Mediacurrent Site Install You can install a full Drupal site. $ cd /path/to/drupal/docroot $ drush si --db-url=mysql://root:root@127.0.0.1/test_d7 --account-pass=abc123 (assumes you have a database setup already) If you need to add the database you can also use the superuser options which will then create the database as well. --db-su=name --db-su-pw=password --accountpass=myadminpass
  • 30. @Mediacurrent Variables List all available variables. $ drush variable-get Set maintenance mode. $ drush variable-set maintenance_mode 1 maintenance_mode was set to "1". [success] Disable maintenance mode. $ drush variable-set maintenance_mode 0 maintenance_mode was set to "0". [success]