Back up and restore a Server
A Server keeps its state in a few places: files in the Server folder, each Environment's Warehouse,
and the Dagster metadata database. This guide lists every piece, what you lose without it, how to
back it up, and the order to restore it in. The commands match the demo Project's
docker-compose.yml and a Server folder set up as in
Run stage and prod on a Mac or by a Promotion
deploy.
Run these commands from the Server folder (the one that holds .env, .adops/, releases/ and
current). Back up when no run is in progress: stop the Server first, or check the Dagster page.
What the Server keeps, and what you lose without it
Files in the Server folder
| What | Where | Lost without it |
|---|---|---|
| Secrets and Server settings | .env |
Every password, ADOPS_ENVIRONMENT, the Dagster database login and the alert webhook URL. Nothing starts until you write it again. Back it up somewhere as safe as the secrets themselves. |
| dlt state | .adops/dlt/<env> and any .adops/dlt/<env>.moved-<UTC time> |
On a Postgres Warehouse, nothing: a Sync restores each Incremental cursor from the Warehouse's _dlt_pipeline_state table on its next run. On a DuckDB Warehouse, that table is in the Warehouse file, so see the next row. Each folder holds an adops-warehouse-identity.json naming its Warehouse by hash only, so restore it with the folder. A .moved- folder is the dlt state of a Warehouse this Environment used before a Warehouse Switch. Keep it only if you may move back. |
DuckDB Warehouse file and its .lock |
inside .adops/ (the path: under warehouse: in adops.yaml, for example .adops/warehouse_stage.duckdb) |
On a DuckDB Warehouse this is the Warehouse: every Synced table, the dbt result and the adops tables below. Losing .adops/ loses all of it. The .lock file next to it holds no data and need not be restored; the next run makes it again. |
| Run Logs | .adops/logs/<env> |
The printed text of past runs, which the Assistant's read_logs tool shows. Runs are not affected. |
| Step output Dagster captured | .adops/dagster/compute_logs |
The stdout/stderr panes of past runs in the Dagster page. Runs are not affected. The Server deletes a run's folder here with the run once it is older than the Retention Period (ADOPS_RUN_HISTORY_DAYS, default 30 days). |
| Server config | server/dagster.yaml, server/workspace.yaml |
The Server does not start. Both come from adops init, so you can also copy them back from a fresh adops init of the same adops version. |
| Release folders | releases/<commit> and the current link |
The Server has no Project to run. Each releases/<commit> holds relative links .env -> ../../.env and .adops -> ../../.adops, and current is a relative link to releases/<commit>. A copy that follows links instead of keeping them breaks this layout (see Restore). The next Promotion deploy also rebuilds a release from Git. |
Each Environment's Warehouse
Back up the whole database (stage's warehouse_stage, prod's warehouse_prod in the demo), not
only the data schemas (raw_<source>, analytics). The adops schema holds the Server's
bookkeeping:
Table in adops |
Lost without it |
|---|---|
_adops_schema_snapshots |
Each table's last known shape. The next run saves the current shape as the new baseline, so a Breaking Change made since the last run is not caught. |
_adops_applied_records |
Which Accepted-change records this Environment already applied. A record can then be applied again, to a later change it was never meant for. |
_adops_deploy_state |
The Settings Marker and the seen Accepted-change records. The next deploy of each Pipeline reruns every Step (a full deploy). |
_adops_step_fingerprints |
The saved Step Fingerprints. The next deploy reruns every Step, and in stage a Branch Environment can defer no Step until stage passes again. |
_adops_load_history |
The Load Records: when each table was last Loaded. Freshness starts counting again from the moment the Server first sees the table, so a table that was already stale alerts late, up to one Stale Limit. |
_adops_freshness_state |
Which tables already got a Stale Alert. A table that is still stale gets one more Stale Alert, and a Recovery Notice owed for an older alert is not sent. |
_dlt_pipeline_state (and dlt's other _dlt_ tables) |
On a Postgres Warehouse, the copy of dlt state that comes back when .adops/dlt is lost. Without both, each Incremental table loads again from the start. |
A Branch Environment keeps the same tables in its own br_<branch>__adops schema (the
<prefix>adops schema) in stage's Warehouse. Losing one only means that Branch rebuilds; it can
be dropped and run again.
The Dagster metadata database
The dagster_meta Postgres (database DAGSTER_PG_DB, the dagster_meta_data volume in the demo)
holds run history, Schedule and sensor on/off state, and the queue. Without it, the Dagster page
shows no past runs and every Schedule and sensor goes back to the state the code declares. adops
does not need it to run Pipelines.
Back up
-
Check free disk, and stop the Server so nothing writes while you copy:
df -h . docker compose --profile server stop dagster_daemon dagster_webserver -
Dump each Postgres database. The commands run
pg_dumpinside the database containers, so the Mac needs no Postgres tools:mkdir -p backup docker compose exec -T dagster_meta sh -c 'pg_dump -Fc -U "$POSTGRES_USER" "$POSTGRES_DB"' > backup/dagster.dump docker compose exec -T warehouse pg_dump -Fc -U warehouse warehouse_stage > backup/warehouse_stage.dump docker compose exec -T warehouse pg_dump -Fc -U warehouse warehouse_prod > backup/warehouse_prod.dumpFor a Warehouse on another machine, run
pg_dump -Fc -h <host> -U <user> <database>against it the same way. -
Copy the Server folder's files, keeping links as links (
tarkeeps them unless told-h):tar -czf backup/server-folder.tgz .env .adops server releases currentOn a DuckDB Warehouse this tar is also the Warehouse backup, which is why the Server must be stopped: a DuckDB file copied while a run writes to it can be unreadable.
-
Start the Server again:
docker compose --profile server up -d --wait --no-build
Keep backup/ off this machine; it holds .env, so treat it as a secret.
Restore
Restore into a Server folder with the Project files and docker-compose.yml in place (a fresh
adops init, or a checkout of the Project repo), and the Server image built. Order matters:
-
Put
.envback, and start only the databases, not the Server.docker composereads every port and password from.envand starts nothing without it. If the daemon starts before the restore, it creates empty Dagster tables and the restore then clashes with them:tar -xzf backup/server-folder.tgz .env docker compose up -d --wait shop warehouse dagster_meta -
Restore the Dagster metadata database:
docker compose exec -T dagster_meta sh -c 'pg_restore --clean --if-exists --no-owner -U "$POSTGRES_USER" -d "$POSTGRES_DB"' < backup/dagster.dump -
Restore each Warehouse. A new
warehousevolume already creates the emptywarehouse_stageandwarehouse_proddatabases:docker compose exec -T warehouse pg_restore --clean --if-exists --no-owner -U warehouse -d warehouse_stage < backup/warehouse_stage.dump docker compose exec -T warehouse pg_restore --clean --if-exists --no-owner -U warehouse -d warehouse_prod < backup/warehouse_prod.dump -
Copy back
.adops/,server/and the release folders at the Server folder root (this writes.envagain too, unchanged):tar -xzf backup/server-folder.tgz -
Check the release links are relative, and make them again if not. Do not rebuild a release with
cp -L,rsync -L/--copy-linksortar -h: those copy.envand.adops/into the release instead of linking them, so runs write state that the next release never sees. Absolute links break as soon as the folder is restored to another path, and inside the containers, which mount it at/project.readlink current # releases/<commit> readlink releases/*/.env # ../../.env readlink releases/*/.adops # ../../.adopsTo make them again for a release
<commit>:ln -sfn ../../.env releases/<commit>/.env ln -sfn ../../.adops releases/<commit>/.adops ln -sfn releases/<commit> current -
Start the Server:
docker compose --profile server up -d --wait --no-build
On a DuckDB Warehouse there is no Warehouse database to restore: step 4 brings the Warehouse
file back inside .adops/. Restore it with the Server stopped, and skip the .lock file if the
backup has one.
Recorded trial
Tried on 2026-11-30 on the Mac host (macOS, Apple silicon, OrbStack with Docker Engine 29.8.2; no
VM), with the demo Project's Postgres Warehouse and a stage Server built from an adops 0.4.0
wheel. The restore went into a fresh adops init in another folder, so the relative links were
tested too.
Commands:
df -h / # 95 GiB free
# Set up as in "Run stage and prod on a Mac": schedule "* * * * *", releases/local, current.
docker compose up -d --wait
docker compose --profile server build --build-arg ADOPS_PACKAGE=/build/adops-0.4.0-py3-none-any.whl
docker compose --profile server up -d --wait --no-build
# After run cbe8e606 passed: Back up, steps 1-3 above (warehouse_stage, warehouse_prod, dagster).
docker compose --profile server down -v # delete every container and volume
mv backup .. && cd .. && rm -rf shop # and the whole Server folder
mkdir restored && cd restored && adops init shop --demo && cd shop # fresh files, new path
mv ../../backup .
# Restore, steps 1-6 above.
What was observed:
| Check | Before backup | After restore |
|---|---|---|
adops._adops_load_history rows |
4 | 4, then 8 after the next scheduled run |
adops._adops_step_fingerprints rows |
3 | 3 |
adops._adops_schema_snapshots rows |
2 | 2 |
raw_shop.orders rows |
100 | 100 |
| Dagster runs | cbe8e606 SUCCESS |
cbe8e606 still listed; the next scheduled run a34ea117 SUCCESS |
readlink current on the Mac and in the daemon |
releases/local |
releases/local in both |
The run after the restore loaded customers (Full Refresh, 20 rows) and 0 rows of the
Incremental orders table, so its cursor came back and nothing was reloaded.
One problem was found and fixed in this guide: the first attempt started the databases before
.env was back, and docker compose refused with required variable WAREHOUSE_PORT is missing a value: set WAREHOUSE_PORT in .env. Restore step 1 now puts .env back first.
Not tried: a DuckDB Warehouse Server, a Warehouse on another machine, and restoring only part of the state (for example the Warehouse without the Dagster database).
Recorded trial 2026-12-01: backup while runs are in progress
Tried on 2026-12-01 18:21–18:35 UTC during the horizon-25 soak, on an AWS m7i-flex.large machine
(Ubuntu 24.04, 2 cores, 8 GB, 19 GB root disk, made by scripts/trial-ec2.sh). It ran a stage
Server on a Postgres Warehouse with two Pipelines, events_sync every 7 minutes and
shop_sync every 10 minutes, a writer adding Source rows every minute, and an image built from an
adops 0.4.1.dev3 wheel (commit b88c6ef). The Fault Script ran it as
scripts/soak/faults.sh backup-under-load.
Back up step 1, stopping the Server, was skipped on purpose. The trial asks whether a backup
taken while runs go on can still be restored, so the script waited until a Server run was in
progress, then dumped with the same commands as step 2: pg_dump -Fc of the Dagster database
(320 KB) and of warehouse_stage (32 MB). It did not take step 3's tar, because on a Postgres
Warehouse dlt state comes back from the Warehouse. The two dumps are separate commands, so they
are not one snapshot taken at a single moment.
How the restore was kept away from the live Server. The dumps were restored into a temporary
folder holding a copy of docker-compose.yml and a .env with SHOP_PORT, WAREHOUSE_PORT and
DAGSTER_PG_PORT raised by 100. That folder was started as a separate compose project,
adops-soak-restore, so it had its own containers and volumes. pg_restore --clean --if-exists --no-owner loaded each dump. After the counts were compared, down -v removed the copy, and
docker compose ls --all listed only the live project, server. The check compares databases
only: no Server was started from the restored copy.
What was observed (the comparison of soak-evidence/horizon-25/09-backup-under-load.rerun-1821.txt):
| Table | Live, before the dump | Restored copy | Live, after the check |
|---|---|---|---|
adops._adops_load_history |
571 | 571 | 573 |
adops._adops_step_fingerprints |
5 | 4 | 5 |
adops._adops_schema_snapshots |
3 | 3 | 3 |
adops._adops_deploy_state |
1 | 1 | 1 |
raw_shop.orders |
907,625 | 907,625 | 907,625 |
raw_shop.events |
7,585 | 7,650 | 7,650 |
raw_shop._dlt_pipeline_state |
199 | 200 | 200 |
raw_shop._dlt_loads |
280 | 281 | 281 |
analytics.customer_stats |
20 | 20 | 20 |
All 571 Load Records in the restored copy were also present live. No restored table had more rows
than the live one read just after the dump; the rows the restored copy has over "before" were
written by the run in progress while the dumps were taken. _adops_step_fingerprints
is compared by presence only, because a run deletes the fingerprints of the Steps it is about to
run and saves them again as each Step passes. The live Warehouse lost no rows, and the Invariant
Checker passed all five Invariants afterwards. The next ticks succeeded: shop_sync at 18:30:14
and events_sync at 18:35:09 UTC.
Three earlier attempts failed in the soak harness, not in the backup: counting dbt's temporary
__dbt_backup tables, comparing fingerprints by row count, and reading a table while dbt swapped
in a rebuilt one (Postgres returned 0 rows). Each was fixed in scripts/soak/faults.sh (commits
8c9d22b, f68cad0, 80fca30), and the rerun above passed.
Not tried: starting a Server from a backup taken under load, a DuckDB Warehouse backup under load (the tar of a DuckDB file during a run can be unreadable, which is why step 1 stays), and restoring over the live Server.