Skip to main content

These steps are for Drupal 8 and 9.

 

Export your database

Order here is important.  First you want to clear all the Drupal caches.  Then export / dump the db the sql database to a file in your home directory.

drush cr
drush sql-dump > path/to/your/file/ourpout/sql-dump-file-name.sql

or

drush sql-dump --extra-dump=--no-tablespaces --result-file=../sql/db-2022-12-07.sql

Without having to manually set the date

drush sql-dump --extra-dump=--no-tablespaces --result-file=../sql/db-$(date +%Y-%m-$d).sql

 

Import Database

Begin by dropping all the tables in your database.  Then with the db empty, import the sql dump back into your Drupal database.

drush sql-drop
drush sql-cli < /path/to/your/file/sql-dump-file-name.sql

or

drush sql-drop
drush sqlc < /path/to/your/file/sql-dump-file-name.sql

 

Related articles

Andrew Fletcher17 Mar 2025
Upgrading to PHP 8.4 challenges with Drupal contrib modules
The upgrade from PHP 8.3.14 to PHP 8.4.4 presents challenges for Drupal 10.4 websites, particularly when dealing with contributed modules. While Drupal core operates seamlessly, various contrib modules have not yet been updated to accommodate changes introduced in PHP 8.4.x. This has resulted in...
Andrew Fletcher20 Feb 2025
Handling duplicate records in Drupal
Duplicate records in Drupal can cause significant issues, particularly when they lead to integrity constraint violations in the database. These errors often occur due to duplicate UUIDs in the `node` table, which can result from programmatic imports, migrations, or unintended database...
Andrew Fletcher17 Feb 2025
The overlooked challenge of migration updates in Drupal projects
When working on Drupal migrations, developers often assume that adding a new field to the process section will seamlessly update existing content. However, unless explicitly handled, Drupal’s migration system does not automatically apply changes to previously migrated records. This oversight can...