DRUSH Update Question

tsaw's picture

Hi Chris,

Love the DRUSH tool!

I have been using it as much as I can and each time am finding new things and ways to take advantage of it.

I have a question - concerning the update and updatecode functions. I didn't see any detailed docs on recommended usage on this and was wondering if you or anyone else that is more knowledgeable on it, could show us the proper way to use these functions?

For example do we put the site in maintenance mode, disable modules prior to update, etc.

Thanks so much!



update is updatecode +

jonhattan's picture

update is updatecode + updatedb. It only update modules, it doesn't do theme updates or drupal upgrades.

I just use it directly. You can put the site in maintenance mode if you prefer. It doesn't exist a command to put a site in maintenance mode but you can get/set variables with drush: drush vset site_offline 1

DRUSH update

tsaw's picture

So do you just put the site in maintenance mode then run the DRUSH update command? Then run update.php and go back online?

or do you disable all the modules - then set the theme back to one of the system themes like garland, etc then run the update, etc?

Can you post a step by step description that you use when you run the update command? or updatecode command?



what I do is just drush

jonhattan's picture

what I do is just drush update.
As I said it does updatecode (download new version of modules) + updatedb (run update.php). I don't use to put the site in maintenance, change the theme or disable modules (what are you going to update if you disable it?). It's not the most secure way but it fits my needs.


tsaw's picture

Hi Jonhattan,

OK thanks for the feedback. I look forward to using DRUSH to the fullest where ever I can - especially the more I learn about it's features.



This places the site into

christefano's picture

This places the site into maintenance mode, runs updates and brings the site back out.

php drush.php eval "variable_set('site_offline', 1);"
drush updatedb
php drush.php eval "variable_set('site_offline', 0);"

Putting the site in maintenance mode isn't a bad idea, especially if you have a custom maintenance page for your theme. Running drush updatedb now clears the cache, too, so drush cache clear isn't necessary.


cem kaan's picture

Can you give some examples like: drush update ....

Almost everything...

emi_bcn's picture

I love drush!! I use it for almost every high level administration tasks: download and enable modules, disable and uninstall modules, update modules, put/drop site in maintenance mode, check DB status, dump/import DB, run cron/update.php/refresh/cache clear, and... upgrade drupal core (yes, I do with some tricky!!)

Some examples:

  • Download and enable cck module:
    drush dl cck
    drush enable cck
  • Run cron:
    drush cron
  • Refresh modules and core updates informartion:
    drush refresh
  • Take a snapshot of the DB:
    drush sql dump > mydb.sql
  • Open a mysql console for processing SQL commands into Drupal DB:
    drush sql cli
  • Clear Drupal cache:
    drush cache clear

PD: Where should I attach a new function for drush pm? It's a needed function for doing Drupal core upgrade: enabledmodules. This function returns 3rd party (contributed) enabled modules, those that must be disabled before upgrading and reenabled after it.

It does not work the way

grantkruger's picture

It does not work the way advertised, but I use drush with SVN, for example, to download or update CCK:

drush dl cck --destination=home/sites/all/modules/drupal_contrib --version-control=svn --svnsync;

Mostly though, I update modules using drush update, but not if the release notes suggest deleted files. I'd really like to find out more about the use of drush with SVN.

Sala kahle,

How to update drupal core

knausz's picture

Hi, can you please share some of your trickery for updating drupal core with drush? do you have a script?

Many Thanks!


RE: How to update drupal core

emi_bcn's picture

Hi Imre,
Of course I can share this script, but first Drush needs to be updated with the functionality I told before: list the third party enabled modules. Without this, the script is just nothing.

I added this functionallity to my own drush installation, and I did so modifying the drush/commands/pm/pm.drush.inc file. Yes, drush README says this is not a Smart Thing, but it works :)

This modification was done over the pm.drush.inc,v 1.32 2009/05/07 21:56:20 version. The messages and comments on the script are on my language, Catalan. You can edit the script and change them. You can use the script from your drupal base dir or from any other on your system if you provide the drupal dir as first argument (not tested, but I'm sure it works).

    What the script does:
  1. Determine actual version of your drupal
  2. Show Drupal status
  3. Download latest version from web with drush (unpacked)
  4. Compare both versions and determine if an update is needed. If not, it exists with exit status 2.
  5. Put your Drupal on maintenance mode
  6. Look for third party enabled modules
  7. Do a DB backup and gzip it
  8. Do a backup of your actual Drupal dir and tar gzip it
  9. Disable third party modules
  10. Remove new Drupal sites directory
  11. Copy some files and directories from old version to new one maintaining file attributes/permissions (cp -pR): sites, robots.txt and .htaccess (you can add more if you need it editing the script and modifying the variable MAINTAIN_FILES)
  12. Rename old Drupal dir to its original name appended with the version and the text "-old"
  13. Rename new Drupal to the name of the old one (replace old with new, and let old there with another name)
  14. Execute updatedb (update.php) to apply changes due to Drupal update
  15. Reenable third party modules (only those enabled before beginning)
  16. Execute updatedb (update.php) to apply changes due to Drupal update related to third party modules
  17. Put your Drupal on non-maintenance mode
  18. Show Drupal status again

After each step, the script asks you if you want to continue. This is done with a bash/script function that you can easily modify to fit your needs. I do so because I'm lazy and don't want to check drush and other commands exit status or output: I do so visually each time.

Note: attachments in this site are making me crazy. Spam filter and non-working CAPTCHA system thinks I'm a spammer... I'll do my best.
Rename pm.drush_.inc_.txt to PATH_TO_DRUSH/drush/commands/pm/pm.drush.inc (overwrite or make a diff to see differences and apply them to your pm.drush.inc)
Rename update_drupal.txt to update_drupal (or whatever, but it's not a text file) and make it executable or execute it with bash

That's all!!

Attaching files...

emi_bcn's picture

Well, as said, spam filter is making me crazy...

Arrrrggghhh!! Hate this.
Where can I upload these files? I can't do this here. No way. No best.

Final Edit
Well, with a little bit of imagination, I finally could upload the files :)

RE: How to update drupal core

knausz's picture

That's a very thorough method, thanks for sharing.

I have a question. If you do not need to be so rigorous, because you're in offline mode, can you bypass the effort of disabling and enabling modules while updating drupal core? I have followed this simple method with success:



RE: How to update drupal core

emi_bcn's picture

Hi knausz,
The script follows steps in UPGRADE.txt . If it's wrong, Drupal core developers are wrong... Just take a look at it. And, of course, if the script does it for you and you don't need to care about it, ¿where's the problem? Is because you dont' want to add the extra functionality to drush?

See you!!

no problems

knausz's picture

Hi emi,

I have no problems, and adding the extra functionality is good. I'm just lazy. But I ran into a problem with the lazy method with Drupal 5. JQuery update will not be done correctly. This module needs the jquery.js file copied over and it also needs the module to be disabled and enabled when the new version of Drupal is installed. Otherwise, jquery will break on your site. Drupal core developers were right... who would have thought?


jQuery Update is definitely

christefano's picture

jQuery Update is definitely an exception since the Drupal 5 version can't benefit from the new theming system. The D6 version does, though, and can be upgraded successfully with Drush.

Update specific modules

snorkers's picture

You can also update just specific modules by using (for example)

drush update cck views og

Which will download the update (if there is one) for the 3 modules shown in the example (cck, views, og), then run update.php. drush updatecode... also works with module names too.

I can not update zen.

cem kaan's picture

An error occurred at function : drush_core_cache_clear [error]
An error occurred at function : drush_pm_updatecode [error]
An error occurred at function : drush_pm_update [error]
drush updated modules but It could not update zen theme.

could be a permissions

ussher's picture

could be a permissions problem on the folder or files. check if the folder is owned by the same user as drush is logged in as:
$ whoami
$ ls -l

if it is a different user, either chmod the folder to the current user, or try sudo to see if that makes any difference.

I was having issues similar to this until i changed apache to run as the same user as the one i logged in with SSH. changing the user was done (for me) by editing /etc/vsftpd.conf and changing the "guest_username" to match the SSH users id. Then i could use drush as the standard user and also make changes via ftp.

I am already root

cem kaan's picture

I am using sudo drush -l domain.com update while I am in drupal installation folder.
Drush says
Code updates will be made to the following projects:
Zen [zen-6.x-1.1]
which is normal then ..

Do you really want to continue? (y/n): y
Module zen path is not available, perhaps the module is enabled but [error]
has been deleted from disk.
Cache cleared.
An error occurred at function : drush_core_cache_clear [error]
An error occurred at function : drush_pm_updatecode [error]
An error occurred at function : drush_pm_update [error]

try sudo drush -l domain.com

ussher's picture

try sudo drush -l domain.com update -v

that will give you the verbose output so you can see if there are any other clues in what the system returns. the -v is for verbose, you could also use

sudo drush -l domain.com update --verbose

cem kaan's picture

--verbose helped me thanks...
Now drush says :

Starting to update Zen code ... [notice]
Module zen path is not available, perhaps the module is enabled but has been deleted from disk. [error]
Cache cleared.
An error occurred at function : drush_core_cache_clear [error]
An error occurred at function : drush_pm_updatecode [error]
An error occurred at function : drush_pm_update [error]

I think it is because of my multi-site structure. Should I add zen to domain themes folder too_?
I am not sure(I do not remember) but maybe I edited some core zen files so probably It can be because of it.

My drush 2.1 update did the same

bvirtual's picture

I just upgraded my drush from 2.0 to 2.1 and did the below.
My experience with Drush, is it does not do themes, unless
the working directory is sites/all/themes and even then it does
not work well for me.

drush updatecode zen

Refreshing update status information ...
Update information last refreshed: Sat, 11/21/2009 - 18:20

Update status information on all installed and enabled Drupal modules:
Name Installed version Proposed version Status
Zen 6.x-1.0 6.x-1.1 Update available

Code updates will be made to the following projects:
Zen [zen-6.x-1.1]

Note: Updated modules can potentially break your site. It's not recommended to update production sites without prior testing.
Note: A backup of your package will be stored to backups directory if it is not managed by a supported version control system.
Note: If you have made any modifications to any file that belongs to one of these projects, you will have to migrate those modifications after updating.
Do you really want to continue? (y/n): y
Module zen path is not available, perhaps the module is enabled but has been deleted from disk. [error]
Cache cleared.
An error occurred at function : drush_core_cache_clear [error]
An error occurred at function : drush_pm_updatecode [error]

root@ns3 themes # ls -l
total 12
drwxr-xr-x 6 apache apache 4096 Feb 13 2009 zen

And I am logged in as root on Gentoo with D6.14 updated yesterday.


LA's Open Source User Group Advocate - Volunteer at DrupalCamp LA and SCALE

did drush install zen for you

ussher's picture

did drush install zen for you in the first place? I sometimes get a similar error when dealing with modules.

Open atrium stores all the modules files at:
/sites/default/modules/contrib/(the modules name)

and drush expects to find it at:
/sites/default/modules/(the modules name)

You could try to first backup your version of zen theme, then install the theme using drush and see where it puts it, upload your version overtop of where drush expects to find it and maybe that would allow drush to do future updates.

(NB: just throwing out thoughts, not a drush expert by any stretch of the imagination.)

I suggest downloading the latest Drush

Chris Charlton's picture

New drush release(s) are out, and fix some issues I experienced. I suggest updating your Drush software.

Chris Charlton, Author & Drupal Community Leader, Enterprise Level Consultant

I teach you how to build Drupal Themes http://tinyurl.com/theme-drupal and provide add-on software at http://xtnd.us

how to check version

cem kaan's picture

Is there any way to check my installed drush version.?
By the way I forgot where did I install drush , I have no idea where is it either

How to find drush file

bvirtual's picture

On unix:

locate drush | grep 'drush$'
find / -name drush -print

On Windows use Search on "drush"

For version, I recommend upgrading.

Alternatively, find the download tar file which has the version in the filename.

The below is how I install drush.
Find the folder that resulted when untarring
and it will have the version number in the folder name.


LA's Open Source User Group Advocate - Volunteer at DrupalCamp LA and SCALE

drush version is writen in Readme

cem kaan's picture

First line of readme includes version.

inside README.txt
// $Id: README.txt,v 1.25 2009/06/04 03:10:41 weitzman Exp $

I wish you could do drush

joejoejoew's picture

I wish you could do drush --version, (you can't as of drush 3.3), but on my system I can do:

cat `locate drush.info`

If you have multiple versions installed, you'll have to use
which drush

to sort out which one you are using.

never mind, I just found

joejoejoew's picture

never mind, I just found http://drupal.org/node/683942 which states you can do

drush status version

* deleting my own post *

lsiden's picture
  • deleted my own post; already answered my own question *