Craft CMS 6 database syncing

Published

Updated

Import the local database to fortrabbit, or download the live one for local development.

Install and deploy run down

  1. Install Craft CMS 6 locally
  2. Set up an app at fortrabbit
  3. Deploy code via Git
  4. Database syncing ← you are here
  5. Assets

Database up

Bring the local database to fortrabbit with DDEV and the frbit CLI. Run these in the local project folder:

# Export the local database
ddev export-db --file=dump.sql.gz

# Replace the database of the environment with it
frbit db push dump.sql.gz {{app-env-id}}

# Deploy again, so craft:up applies the project config
frbit environments deploy {{app-env-id}}
shell

Then log in to the Control Panel at /admin with the local account. Without DDEV or the frbit CLI, see database up via terminal or via a MySQL GUI.

Start empty on fortrabbit

To start with an empty site instead, install Craft over SSH after the first deployment:

ssh -t {{app-env-id}}@ssh.{{region}}.frbit.app php artisan craft:install
shell

It asks for the admin account and the site settings, and to confirm the run in production. The next deployment deletes the project config the install wrote on the environment, and craft:up writes it again from the database. To develop locally, pull the database down and commit the project config from there.

Database down

Download the live database to develop locally with current content:

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

Without DDEV or the frbit CLI, see database down via terminal or via a MySQL GUI.

Written by humans and AI in collaboration.

AI use & editorial processEdit on GitHub ↗