Database
The running site's database lives inside the database container - the
.data/db.sql file on the host is only a dump used for imports and exports.
Removing the container (for example, with ahoy reset) discards the live
database, and the next build re-creates it from the dump.
Fetching and exporting run on the host (they move dump files around), while refreshing runs inside the containers (it imports into the running database) - the tabs below reflect that difference.
Fetching database
To fetch the database with the latest data from the production environment,
fetch the latest database dump into the .data directory.
- Ahoy
- Host
# Fetch latest database dump (uses cache if fetched today)
ahoy fetch-db
# Force a fresh fetch regardless of cache
ahoy fetch-db --fresh
# Fetch latest database dump (uses cache if fetched today)
./vendor/bin/vortex-fetch-db
# Force a fresh fetch regardless of cache
VORTEX_FETCH_DB_FRESH=1 VORTEX_FETCH_DB_FORCE=1 ./vendor/bin/vortex-fetch-db
The database dump is stored in the .data directory instead of being directly
imported into the local environment to allow for caching and reusing the
database dump without needing to fetch it every time you need to refresh
the local environment.
You can manually fetch the database dump from the production environment,
name it db.sql, and place it in the .data directory.
Refreshing database
There are 2 distinct ways to load the dump from .data into the running
database container - pick the one matching what you need.
Import and run updates
ahoy provision imports the dump and applies all the provisioning steps:
database updates, configuration import, cache rebuilds and deploy hooks. Use
it any time you need the local environment reset to a fully updated state.
- Ahoy
- Docker Compose
ahoy provision
docker compose exec cli ./vendor/bin/vortex-provision
Import only
ahoy import-db imports the raw dump without running any updates,
configuration imports or scripts. Use it to quickly reset the database
contents to the state captured in the dump.
- Ahoy
- Docker Compose
ahoy import-db
docker compose exec cli ./vendor/bin/vortex-import-db
Exporting database
Export timestamped database dumps from the local environment.
- Ahoy
- Host
# Export current database to .data directory
ahoy export-db
# Export current database to .data directory
./vendor/bin/vortex-export-db
You can use these dumps to restore the local environment to a specific state:
rename the dump file to .data/db.sql and run the import command.
Cache tables are exported with their structure but without their data, because
Drupal rebuilds them on demand and their contents would only inflate the dump.
Set VORTEX_EXPORT_DB_FILE_STRUCTURE_TABLES to a comma-separated list of table
names, each of which may use the * wildcard, to choose which tables are
exported this way. Set it to an empty value to export the data of every table.
➡️ See Drupal > Provision