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
- Install Craft CMS 6 locally
- Set up an app at fortrabbit
- Deploy code via Git
- Database syncing ← you are here
- 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}}
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
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
Without DDEV or the frbit CLI, see database down via terminal or via a MySQL GUI.