Skip to main content

Performing a Non-Destructive Drush Site Installation Without Database Reset

Updated by Tim Rabbetts on
Installing a Drupal Site with Drush Without Dropping the Database

Drush is a powerful command-line tool for managing Drupal sites. It provides a swift method to install Drupal sites, including setting up the necessary database configurations. While the conventional approach using the drush site:install command reinstalls Drupal and creates a new database, there might be scenarios where you need to install Drupal without dropping or recreating the existing database.

Why Preserve the Existing Database?

In certain development scenarios, especially when working in a team or maintaining a continuous integration workflow, you may want to preserve the existing database to save the data or to avoid configuration discrepancies. This is essential to maintain the integrity and consistency of your data throughout the development lifecycle.

Step-by-Step Guide to Install Drupal Using Drush without Dropping the Database

1. Prepare the Environment

Before running the installation commands, ensure that your development environment is set up properly. This includes having Drush installed and configured correctly. If you need guidance on installing Drush, please refer to the official Drush documentation.

2. Use the Existing Database Configuration

Assuming that you have an existing database that you want to retain, ensure that your Drupal setting’s file (typically located at sites/default/settings.php) is configured to connect to this database.

3. Perform a Site Install Command

Utilize the drush site:install command with specific parameters to prevent the database from being dropped. The command should be structured as follows:

drush site:install --existing-config

The --existing-config option tells Drush to use the configuration already present in the configuration directory. This option is helpful when you have a pre-populated settings file and avoid data lose.

4. Verify Installation

After executing the command, check your website to ensure that it performs as expected without any loss of data or functionality. It is advised to backup your database and site code before executing such operations.

Conclusion

Installing Drupal using Drush without dropping the existing database is a handy approach for developers looking to maintain the integrity and continuity of data in a development environment. Properly leveraging Drush's capabilities can streamline workflow and reduce setup time drastically.

Add new comment