Database syncing with Drupal

Published

Reviewed

Move the Drupal database between DDEV and fortrabbit with two commands each way. The frbit CLI dumps and imports on the environment over SSH, DDEV handles the local side.

Install and deploy run down

  1. Install Drupal locally
  2. Deploy Drupal to fortrabbit
  3. Database syncing ← you are here
  4. Files syncing

Database down

Pull the database once editors work on the live site, to develop locally with current content:

frbit db pull {{app-env-id}}
ddev import-db --file={{app-env-id}}.sql.gz
shell

frbit db pull runs mysqldump on the environment over SSH and writes {{app-env-id}}.sql.gz to the current folder. No database password reaches the local machine. ddev import-db replaces the local database.

Database up

Push the local database to bring a new site up, or to replace the live content on purpose:

ddev export-db --file=local.sql.gz
frbit db push local.sql.gz {{app-env-id}}
shell

frbit db push asks to type the environment ID first. It dumps the current database on the environment to /data/home/ before the import, and prints the command to restore it when the import fails.

MySQL and MariaDB

DDEV runs MariaDB for Drupal by default, fortrabbit runs MySQL. A Drupal database dump moves between both in either direction. To match production, create the DDEV project with --database=mysql:8.4.

Without the frbit CLI

The MySQL export and import guides cover the same with ssh, mysqldump and a MySQL GUI.

Written by AI, lectured by a human.

AI use & editorial processEdit on GitHub ↗