DRUSH Update Question

Events happening in the community are now at Drupal community events on www.drupal.org.
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!

Tim

Comments

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?

Thanks!

Tim

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.

THANKS!

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.

Blessings!

Tim

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.

example

cem kaan's picture

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

Almost everything...

emi_bcn's picture

Hello!!
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,
Grant

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!

-Imre

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...

Edit
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:

http://studioandrew.com/node/1838

Thanks!

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!!
emi

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?

Thanks,
Imre

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.

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$'
or
find / -name drush -print

On Windows use Search on "drush"

For version, I recommend upgrading.

Corrections:
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.

Peter

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

drush version is writen in Readme

cem kaan's picture

thanks...
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 *

drush

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: