Home / Comment permalink

Use Drush to Upgrade from Drupal 6 to Drupal 7

The Drush site-upgrade command supports upgrades from Drupal 6.x to Drupal 7.x. If you are just doing a minor version upgrade (e.g. 6.20 to 6.21), please use drush pm-update instead.

To begin, make sure that your current Drupal installation is running the most recent version of Drupal 6.x (currently 6.22). The most recent version is listed on the Drupal project page

Upgrade a Copy of your Site

site-upgrade always upgrades from the current Drupal site to an empty Drupal site. Drush never alters your source site, so it is safe to run this command from within your production site. It is necessary to create a site alias to describe the destination site. Site aliases are described in drush topic docs-aliases. A canonical site alias is adequate to define your target site for upgrade:

$aliases['onward'] = {
  'root' => '/path/to/upgraded/drupalroot',
  'uri' => 'http://onward.mysite.org',

Optionally, you might also want to define a db_url to specify the name of your target database. If you do not, drush will compose a database name for you based on the name of your site alias.

Running the Site-upgrade Command

Drush will upgrade the current bootstrapped site (D6), and will put the result in the target site specified by the argument to the command. For example:

drush site-upgrade @onward

The site-upgrade command will perform the following operations:

  • Download latest stable release of Drupal 7 and store the files in the target site.
  • Write a new settings.php file with an appropriate databases structure for the new target site.
  • Make a copy of the SQL database for the new site.
  • The default theme for the new site will be set to Garland", and the admin theme will be set to Seven.
  • All non-core extensions will be disabled in the target database, and updatedb will be run on Drupal core.
  • All of the modules disabled in the previous step will be downloaded again, if they have a release for Drupal 7 (a dev snapshot is OK).
  • drush updatedb will be run again to update the non-core modules.
  • All of the non-core modules will be enabled again.

Before Drush begins this process, it will first print out a list of warnings for any modules that may not be ready to upgrade yet. Please read all of these messages carefully before proceeding. Here are some of the situations you may encounter.

  • If a module has no recommended release, then drush will continue, downloading an available release for the upgrade.
  • If a module has no release at all, then Drush will skip it. The module's data will remain in the database.
  • You may discover that some modules, such as date_api, might cause the Drupal core updatedb to fail. In this instance, you may use the --uninstall option to list the modules to uninstall prior to upgrade. Modules uninstalled in this manner will have all of their data removed from the target database; the database of the source site is not affected.

When Drush is enabling the modules in the upgraded site, if there are any new dependencies, they will also be identified and downloaded if possible. For example, views-7.x depends on the ctools module from the Chaos tool suite, whereas views-6 did not; drush will therefore download and enable ctools when upgrading the Views module from Drupal 6 to Drupal 7.

There will still be some work left to do after the site-upgrade command has completed; for example, you will still need to port your theme and any custom modules to the new version of Drupal, and some contrib modules may require additional work to update their configuration settings. Using site-upgrade will save you a considerable amount of time. There is no risk in trying it; if it does not work, you can always start over, or run it at a later date when more contrib modules have been updated. If you do run site-upgrade a second time on the same site, drush will ask you if you want to replace the existing target site, effectively starting over from the beginning, or re-use the code that is already present. In the latter case, drush will use the existing code, but will re-copy the source database and run updatedb on it again. This allows you to attempt to fix any non-working contrib modules yourself to get your site-upgrade working.



Posted on by Yannick Lyn Fatt.

If I run a Drupal Multi-Site setup how would this handle running database updates for the other sites? And what about modules that exist but are not enabled, will they be upgraded to their D7 versions as well?

Posted on by Rick Umali.

I wish I had tried this on my own D6-to-D7 upgrade! It looks like this would have handled a lot of the mechanical tasks (e.g. module and dependencies download, settings.php, etc.).

Once the site-upgrade is finished, and you want to deploy the upgraded Drupal, you'd only need to delete (or move aside) the old Drupal (at /path/to/old/drupalroot, for example), and then copy the /path/to/upgraded/drupalroot into its place?

Posted on by mweitzman.

The best practice for going live is to make your D7 site live at a temporary domain like new.example.com. Once you are ready to cut over to the D7 site, change your www.example.com virtual host (or equivalent) to point to the new.example.com codebase. This technique makes rollback easier.

Posted on by KatherineK (not verified).

The drush command 'site-upgrade' could not be found.

Posted on by Mark Fullmer (not verified).

site-upgrade is an add-on. The function needs to be installed. Follow instructions here:
https://drupal.org/project /drush_sup

Posted on by Dun Tuk.

the code above should use () and not {}

Posted on by ñull (not verified).

Not only the round brackets, also the word array is missing. I wasted ages on this error. It should be:

$aliases['onward'] = array (
'root' => '/path/to/upgraded/drupalroot',
'uri' => 'http://onward.mysite.org',

Posted on by Rob (not verified).

The 6>7 drush site upgrade command is now a separate module: http://drupal.org/project/d rush_sup

Posted on by Charlie (not verified).

Can you explain "to an empty Drupal site"? Are you referring to an empty folder somewhere on the server, a new database, or what exactly?

Posted on by S L.

The site that should be aliased is the new site and also the alias should be inside php brackets.So this should be something like that:
$aliases['test'] = array(
'root' => '/var/www/d7',
'uri' => 'localhost',

Posted on by FranK (not verified).

I have followed the whole procedure and it looks like working until 12-a. At that point, all the tables from the source database are dropped and the system stops because it can't find the tables.

Posted on by chao (not verified).

me too ,Now you solve this problem?

Posted on by Colan Schwartz.

This happens if "db-url" isn't set properly. See https://drupal.org/node/1882650 (Source DB tables get dropped if db-url not set) for details.

I would have made that a properly named link, but this forum doesn't allow the necessary HTML tag.

Posted on by mhmd (not verified).

where and how to put the alias piece code ?

Posted on by mrkcp (not verified).

Hi everyone!
I have kind of dilemma.
I run Drupal 6 website and want to upgrade. I found a service - cms2cms that upgrades Drupal automatedly without using codes , moving the content to the new version. But it doesn't move design and modules. Does the drush perform more complex migration?

Posted on by Deepesh Agarwal.

Pls. edit and correct this dangerously wrong post which is not only providing wrong, incomplete information but suggesting that this can be safe on a production site ?

Posted on by Pat Pathade.

Have you actually anything and have evidence that the instrcutions are incorrect and dangerous? Or are you just surmising from the other comments? Please share your experimental and actual experience and observations

Posted on by Pat Pathade.

Tried with the command "drush @test site-upgrade" (where @test is site-alias).
But getting an error i.e. "Command site-upgrade needs the following modules installed/enabled to run: [error]
The drush command 'site-upgrade' could not be executed."

Same thing happened with "drush pm-update" command.

Site is hosted on Acquia Cloud.

Any help will be appreciated.

Posted on by Pat Pathade.

Our Update module was not enabled hence this error. Enabling it moved us past this error

Posted on by Dave (not verified).

I am upgrading on a shared host--Bluehost. I created a new database and user for the D7 install and added that information to the alias like this:

$aliases['mynewsite'] = array(
'root' => '/home1/username/public_html/mysitename',
'uri' => 'http://www.mysitename.org' ,
'db_url' => 'mysql://username_newdbuser:password@localhost/username_newdb ',

when I start the upgrade process, of course it complains about many things, but then it fails because it cannot connect to the new database. On exit, it reports:

Drush was not able to start (bootstrap) the Drupal database.
Drush was attempting to connect to:
Drupal version : 6.28
Site URI : mysitenamedb
Database driver : mysql
Database username : olddatabaseusername
Database name : mysitenamedb

it is getting the wrong database information somehow. If I drush status from my 6.28 home, everything looks ok. If I go into the new directory I set up for the D7, and drush status, I see the bogus connection information as well.

The database username is copied from the D6...and, I see it also copied settings.php...but the database name appears to be "mysitename" . "db" instead of what I defined in the alias.

Does this make any sense? Sorry, I am changing the text to hide my actual username/passwords, etc.

basically, I have my current site at $HOME/public_html/currentsitedomain.org and just made a new directory at $HOME/public_html/mysitename with the intention of setting up the D7 version there and then copying it over if it worked.

Posted on by Emiliano (not verified).

"site-upgrade always upgrades from the current Drupal site to an empty Drupal site"

Can the destination site be a copy of the production site?
Should the destination site be a Drupal 7 site?

Posted on by Nathan Bennett.

Hi - I'm trying to use drush site-upgrade to migrate a D6 site to D7, but there is no release for 6.x, so I can't run it from the source site, and when I run it on the clean D7 site, I get this error:

Command site-upgrade requires Drupal core version 6 to run

What is the correct protocol to use this command?

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Filtered HTML

  • Use [acphone_sales], [acphone_sales_text], [acphone_support], [acphone_international], [acphone_devcloud], [acphone_extra1] and [acphone_extra2] as placeholders for Acquia phone numbers. Add class "acquia-phones-link" to wrapper element to make number a link.
  • To post pieces of code, surround them with <code>...</code> tags. For PHP code, you can use <?php ... ?>, which will also colour it based on syntax.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <h4> <h5> <h2> <img>
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.