The Easy Way to Update Drupal Core

Drupal gets regular updates, and it’s important to keep on top of them. Unlike WordPress, Drupal isn’t set up to update its own core automatically, and if you’ve been updating your site manually with mysqldump, ftp, etc., you’re working too hard. There’s a great tool for doing it from the command line: drush.

Presumably, you have pear installed on your Drupal site, so installing drush is very easy:

pear channel-discover pear.drush.org
pear install drush/drush

Once you have drush installed, navigate to the root of your Drupal site. Make a copy of the sites/ folder:

cp -r sites/ sites-bak/

Next, use drush to make a backup of the MySQL database:

drush sql-dump --result-file=../myDrupalSite.sql

Specify your result-file path to suit your needs. Now, put your site into maintenance mode:

drush vset --exact maintenance_mode 1
drush cache-clear all

Update Drupal core:

drush up drupal

When asked whether you “really want to continue, enter “y” and press return. drush will update your site core, perform any necessary database upgrades, and (by default) keep a backup copy of the existing site. Now, put your site back online:

drush vset --exact maintenance_mode 0
drush cache-clear all

Using drush is a lot quicker, safer, and more efficient than doing your core updates manually — check it out!

Leave a Reply

Your email address will not be published. Required fields are marked *