Drush notes

Update Drupal core

How to update Drupal core with Drush

(Drush is a command line tool for Drupal).

1. Backup everything (all files, databases, etc)

2. Put your site in maintenance mode

Either from Drupal interface or with drush:
(commands for Drupal 7)
drush vset --always-set maintenance_mode 0
drush cache-clear all

3. Save your .htaccess-file, robots.txt and favicon.ico somewhere

…If you have modified them

4. Update Drupal with drush

drush up drupal

5. Check that everything works

Go around your site and test everyhting!

6. Put your site online again

Take your site away from maintenance mode either from Drupal interface or with drush (command for Drupal 7)
drush vset --always-set maintenance_mode 0
drush cache-clear all

 

 

Below copied from http://orga.cat/posts/most-useful-drush-commands


 

Here I will try to maintain a drush cheat sheet with the list of drush commands I use most often. Full and short version of commands are used interchangeably.

See main information and status of the site

Clear the cache

Clear the cache, even if Drupal is broken

sql-query executes sql queries in the database where Drupal is installed.

Download the last recommended release of 2 modules

Download a -dev version of a module

Seems that adding --package-handler=git_drupalorg is not needed anymore.

Download the git HEAD version of a module

Short answer: drush does not do that.
Long answer: See http://drupal.stackexchange.com/q/62934/10086

Enable a module

-y skips the confirmation question. Some drush commands may miss the -y part, a workaround for this that always works is putting it before:

If the module is missing and its name matches a project name, drush will automatically download the module from drupal.org.

Disable a module

Disable a module, even if Drupal is broken

Source: https://drupal.org/node/157632

Uninstall a module

See if a module is available

See if a module is enabled

See all contrib and custom modules that are enabled

Update a module

Update Drupal

Update all contrib modules and Drupal

Run update.php

Send an e-mail

Delete a field

Delete an instance of a field

Manually delete a field and all its data (not recommended)

Set a password for a user

Block a user

Log all users out

Log out a specific user

Get a one-time login link for the Administrator user

Run cron

Run Ultimate Cron

Set a variable

Get the value of a variable

See last logged events (watchdog)

See logged events in real time

Run a php script with Drupal bootstrapped

Use --uri to specify the host name. Use --root to specify the site directory (in cron, for example):

Run custom code

Repopulate database tables used by menu functions

See https://api.drupal.org/api/drupal/includes!menu.inc/function/menu_rebuild/7

Rescan all code in modules or includes directories, storing the location of each interface or class in the database

Useful when moving installed modules. See http://drupal.stackexchange.com/q/17657/10086
If does not work because Drupal cannot bootstrap, do it that way:

Update a Feature with database changes

Revert a Feature, update the database to match the code

Revert all features

Useful in deployment scripts.

Change error level

Show only errors and warnings

Show all

Hide everything

Enable maintenance mode

Open a MySQL console logged in

Import a backup of the database

Export a backup of the database

Remove all database tables (empty the database)

Useful before importing a database backup.

See all drush aliases

Use an alias

Flush image styles

Install Drupal

Delete all content of specific content types

Note that you need Devel and Devel Generate modules. Alternatives are drush migrate-wipe andDelete all module.

Delete content type

Generate random content

Create a boilerplate for a new module

See Module Builder.

More…

A more general and exhaustive list can be found here: https://groups.drupal.org/node/28088
Full documentation – Contrib modules not included – is available at http://drush.ws
And check www.drushcommands.com, is awesome!