Step-by-step tutorial on how to upgrade from Drupal 7 to Drupal 10

here is a step-by-step tutorial on how to upgrade from Drupal 7 to Drupal 10, considering that Drupal 7 is on Server 1 and Drupal 10 will be on Server 2.

Step 1: Prepare Your Drupal 7 Site on Server 1

1.1. Backup Your Site

Before you begin the upgrade process, it is crucial to back up your entire Drupal 7 site, including the database and files.

# Backup database
drush sql-dump > drupal7-database.sql

# Backup files
tar -czvf drupal7-files.tar.gz /path/to/drupal7

1.2. Update Drupal 7 Core and Modules

Ensure your Drupal 7 site is running the latest core version and that all contributed modules are up to date.

# Update core
drush pm-update

# Update contributed modules
drush pm-updatecontrib

Inventory of Modules

Identify which modules have Drupal 8/9/10 versions available. This will help in planning the migration and ensuring that you only migrate compatible modules.

drush pm-list --type=module --status=enabled

Step 2: Set Up the New Drupal 10 Site on Server 2

2.1. Install Drupal 10

Download and install a fresh Drupal 10 site on your new server (Server 2).

# On Server 2

# Navigate to the web root directory
cd /var/www/html

# Download Drupal 10
composer create-project drupal/recommended-project drupal10

# Move to the new directory
cd drupal10

# Set up the site
composer install

2.2. Set Up the Drupal 10 Environment

Ensure that your web server and PHP configurations on Server 2 meet the requirements for Drupal 10 (PHP 8.1 or higher).

Step 3: Transfer Drupal 7 Data to Drupal 10

3.1. Install and Enable Required Modules on Drupal 10

On Server 2, install the Migrate, Migrate Drupal, and Migrate Drupal UI modules on your Drupal 10 site.

# On Server 2

composer require drupal/migrate_drupal
composer require drupal/migrate_drupal_ui

# Enable the modules
drush en migrate migrate_drupal migrate_drupal_ui -y

3.2. Transfer Database and Files

Copy the backup files from Server 1 to Server 2.

# On Server 1
scp drupal7-database.sql user@server2:/path/to/destination
scp drupal7-files.tar.gz user@server2:/path/to/destination

Extract the files and import the database on Server 2.

# On Server 2

# Extract files
tar -xzvf drupal7-files.tar.gz -C /path/to/drupal10/sites/default/files

# Import database
drush sql-cli < /path/to/drupal7-database.sql

3.3. Configure Settings

Update the settings.php file in Drupal 10 to point to the imported Drupal 7 database.

# On Server 2

# Copy the default settings file
cp sites/default/default.settings.php sites/default/settings.php

# Edit settings.php to configure database connection
nano sites/default/settings.php

# Update the following settings with the details of your imported Drupal 7 database
$databases['default']['default'] = array (
  'database' => 'drupal7_database_name',
  'username' => 'drupal7_database_user',
  'password' => 'drupal7_database_password',
  'host' => 'localhost',
  'port' => '',
  'driver' => 'mysql',
  'prefix' => '',
);

Step 4: Run the Migration on Server 2

4.1. Prepare the Migration

Install the migrate_tools module to provide Drush commands for migration.

# On Server 2

composer require drupal/migrate_tools

# Enable the module
drush en migrate_tools -y

4.2. Perform the Migration

Use Drush to perform the migration from Drupal 7 to Drupal 10.

# On Server 2

# Initialize the migration
drush migrate:setup

# Perform the migration
drush migrate:import --all

Step 5: Post-Migration Tasks

5.1. Verify Content and Configuration

Check that all content, users, and configuration have been migrated correctly. Compare the new Drupal 10 site with your original Drupal 7 site.

5.2. Install and Configure Themes

Install and configure a theme that is compatible with Drupal 10. If you were using a custom theme in Drupal 7, you might need to port it to Drupal 10.

# On Server 2

composer require drupal/my_theme

# Enable the theme
drush then my_theme

5.3. Install and Enable Required Modules

Install and enable any additional modules that are needed for your site to function as expected. Ensure that they are compatible with Drupal 10.

# On Server 2

composer require drupal/module_name

# Enable the module
drush en module_name -y

Step 6: Testing and Quality Assurance

6.1. Functional Testing

Test all the functionalities of your site to ensure everything is working as expected. Pay special attention to custom functionalities and complex content types.

6.2. Performance Testing

Run performance tests to ensure the new site performs well under load.

6.3. Security Audit

Perform a security audit to ensure that the new site is secure and follows best practices.

Step 7: Go Live

7.1. Final Backup

Take a final backup of your Drupal 7 site before switching to the new site.

7.2. Switch DNS

Update your DNS settings to point to the new Drupal 10 site on Server 2.

7.3. Monitor the New Site

Monitor the new site closely after going live to catch any issues early and ensure a smooth transition.

Step 8: Maintenance

8.1. Regular Updates

Keep your Drupal 10 core and modules updated to the latest versions to ensure security and performance.

# On Server 2

# Update core
composer update drupal/core --with-all-dependencies

# Update modules
composer update drupal/module_name

8.2. Backup and Monitoring

Regularly back up your site and monitor its performance and security.

# On Server 2

# Regular backup example
drush sql-dump > drupal10-database.sql
tar -czvf drupal10-files.tar.gz /path/to/drupal10

By following these steps, you can successfully upgrade your Drupal 7 site on Server 1 to Drupal 10 on Server 2, ensuring that your content, configuration, and functionality are preserved and enhanced with the latest features and security improvements in Drupal 10.