Search form

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:

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.

Comments

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?

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?

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.

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:
<?php
$aliases['test'] = array(
'root' => '/var/www/d7',
'uri' => 'localhost',
);
?>

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?

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

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]
update.
The drush command 'site-upgrade' could not be
executed."

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.

Plain text

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.