How to upgrade an existising site from Drupal 7 to Drupal 9
1. Evaluate Your Current Site
- Audit the Drupal 7 site:
- Check which modules you're using (both core and contributed).
- Identify any custom code (modules or themes).
- Take note of deprecated modules, custom code, and data structure complexity.
2. Update to the Latest Version of Drupal 7
- Before migrating, make sure your site is on the latest stable version of Drupal 7. This ensures compatibility and reduces upgrade issues.
- Update all contributed modules and themes to their latest stable releases.
3. Set Up a New Drupal 9 Installation
- Install a fresh version of Drupal 9 on a new environment (can be a local development or staging environment). This will serve as the destination site for your data migration.
4. Install the Migration Tools
You’ll need the following key modules in the Drupal 9 site to migrate data from Drupal 7:
- Migrate
- Migrate Drupal
- Migrate Drupal UI
These can be enabled via Composer:
composer require drupal/migrate_upgrade drupal/migrate_tools drupal/migrate_plus
Enable the required modules via the UI or Drush:
drush en migrate migrate_upgrade migrate_tools migrate_drupal_ui
5. Review Custom Code and Contributed Modules
For each custom module or theme, check:
- If a Drupal 9 compatible version is available.
- If not, you’ll need to either rebuild the functionality in a custom Drupal 9 module or find alternative contributed modules that support Drupal 9.
Use tools like:
- Drupal Upgrade Status module: This scans your site and identifies which contributed modules need to be upgraded or replaced for compatibility with Drupal 9.
- Drupal Module Upgrader: This can assist in converting custom Drupal 7 modules to Drupal 9.
6. Plan Data Migration
Drupal 7 to 9 is a migration (not an in-place upgrade), so your content, users, configurations, and custom entities will need to be migrated.
Go to Extend > Migrate Drupal UI. This provides a user-friendly interface for migration.
- Migration Wizard will guide you through migrating content, configurations, and more from Drupal 7 to 9.
- If you need more control, use the Migrate API to manually configure the migration via custom migration scripts.
7. Run the Migration
Using the Migrate UI, connect to your existing Drupal 7 database and migrate its content into Drupal 9.
Alternatively, you can run the migration with Drush commands like:
drush migrate:upgrade --legacy-db-url=mysql://user:password@localhost/drupal7db --legacy-root-path=/path/to/drupal7
8. Post-migration Tasks
Review and Test:
- After migration, carefully test the site for functionality and content accuracy.
- Check your custom modules and themes for issues.
SEO and URL Structure:
- Ensure that your URL aliases and redirects are working correctly.
- Migrate any custom SEO configurations.
9. Enable or Reinstall Modules in Drupal 9
- Some modules that were native to Drupal 7 may now be part of the core, or new contributed modules may need to be installed. You’ll need to:
- Reinstall or re-enable these modules in Drupal 9.
- Check for their configurations, which may require adjustments.
10. Final Testing and Launch
- Perform a final round of testing with:
- Different user roles and workflows.
- Performance checks.
- Backup your new Drupal 9 site.
Once satisfied with the upgrade, you can proceed to move the site to production.