Database Migrations and Backups
This page describes how dinary-server manages its DuckDB files and how to back them up safely.
Database files
The server stores data in the data/ directory:
config.duckdb- reference data such as categories, groups, tags, stores, and mappingsbudget_YYYY.duckdb- yearly transactional data such as expenses and sync jobs
Migrations
Schema changes are managed with yoyo migrations.
When migrations run automatically
- On application startup,
config.duckdbis migrated to the latest version automatically - When a yearly budget database is opened for the first time,
budget_YYYY.duckdbis created and migrated automatically - During
inv deploy, the deploy script applies config migrations before restarting the service
For a fresh installation, no manual migration step is usually required.
Manual migration commands
If you want to apply migrations explicitly on the server:
inv migrate-config
inv migrate-budget --year=2026
Use migrate-budget for any year whose budget_YYYY.duckdb file already exists or is about to be created.
Backup strategy
DuckDB stores everything in local files, so backup is file-based.
What to back up
Back up the whole data/ directory, including:
config.duckdb- all
budget_YYYY.duckdbfiles data/.deployed_versionif you want to keep deployment metadata
Recommended times to back up
Create a backup:
- before running
inv deploy - before applying manual migrations in production
- before any manual edits to files in
data/
Backup command
To download server data locally:
inv backup
By default this copies the remote data/ directory into ./backups/.
You can also choose another destination:
inv backup --dest=./my-backups
Restore
To restore from a backup:
- Stop the running service
- Replace the contents of
data/with the backed up files - Start the service again
- Run
inv migrate-configandinv migrate-budget --year=YYYYif you want to force migration checks after restore
Because the database is file-based, restore is usually just a file copy operation.
Practical guidance
- Keep at least one backup from before every deploy
- Treat
data/as the source of truth - Do not edit DuckDB files while the service is actively writing to them
- If you copy files manually, prefer doing it while the service is stopped