Skip to main content

Roll back a failed migration

The core loop, end to end, on the demo project.

1. Put some state in every service​

Postgres
docker compose exec -T postgres psql -U postgres -d demo <<'SQL'
CREATE TABLE orders (id serial PRIMARY KEY, tenant_id int, total numeric);
INSERT INTO orders (tenant_id, total) SELECT (n % 3) + 1, n * 1.5 FROM generate_series(1, 1000) n;
SQL
Redis
docker compose exec -T redis redis-cli SET orders:count 1000
MinIO
docker compose exec -T minio sh -c 'mkdir -p /data/demo && echo "report v1" > /data/demo/report.txt'

2. Take the savepoint​

arcave savepoint create pre-migration --description "orders table, 1000 rows"
stderr + stdout
✔ savepoint.create pre-migration 10.2s
├── ✔ project.introspect 0.1s
├── ✔ savepoint.hold 0.2s
├── ✔ savepoint.capture pre-migration 5.2s
└── ✔ savepoint.release 3.6s

Savepoint pre-migration · 019e843e-1650-7000-8000-000000000000 · 19:41:12 · stored 273 MB
count size stored
volumes 3 48.9 MB 4.7 MB
layers 3 260 MB 40.6 KB
images 3 1.1 GB 268 MB

roll back: arcave -p arcave-demo rollback pre-migration

The summary counts what the savepoint holds: three volumes, three writable layers and three images, one per service. The JSON is trimmed to the PostgreSQL and Redis volumes and one entry of each other kind: the real record holds the MinIO volume as well, and a layer and an image for every service. Every service was captured, including the anonymous volume behind Redis, which arcave had to ask the Docker daemon about through the redis container. A layer's stored_bytes is what it adds over its image, which is why it is so much smaller than its size_bytes.

The log in the JSON tab is what --progress log writes off a terminal, trimmed to one image and one writable layer, the timestamps left out. Each line names its step by its path in the tree, and a step that measures bytes ends with what it read, stored and found already stored. The three volumes are captured concurrently, so their lines interleave. Then each distinct image is kept once, and every container's writable layer is committed over it.

3. Run a migration that goes wrong​

docker compose exec -T postgres psql -U postgres -d demo <<'SQL'
ALTER TABLE orders ADD COLUMN region text;
UPDATE orders SET region = 'eu' WHERE tenant_id = 1;
ALTER TABLE orders ALTER COLUMN region SET NOT NULL;
SQL
It fails, halfway
ERROR: column "region" of relation "orders" contains null values

The ALTER failed, but the column and the partial backfill are still there. And the application already updated its cache:

docker compose exec -T redis redis-cli SET orders:schema_version 15

The environment is now inconsistent in two services at once. This is exactly the state that is tedious to unwind by hand.

4. Roll back​

arcave rollback pre-migration
stderr + stdout
✔ rollback pre-migration 12.1s
├── ✔ project.introspect 0.1s
├── ✔ rollback.prepare 1.8s
├── ✔ rollback.safety-snapshot 3.9s
├── ✔ rollback.apply 5.3s
└── ✔ rollback.cleanup 0.0s

Rolled back to pre-migration · 019e843e-1650-7000-8000-000000000000 · 2026-06-01 19:41:12
volumes 3
layers 3
safety taken

Warnings (1)
! the containers run on the savepoint's writable layers
→ `docker compose up` of your compose file recreates them on its images and drops those layers

undo it: arcave -p arcave-demo rollback 019e8491-04c8-7000-8000-000000000000

arcave first reads what the savepoint says it holds, then loads the writable layers back into the daemon — rollback.prepare, all before anything is stopped, so a savepoint that cannot be rebuilt leaves the project running. Then arcave takes the safety snapshot of the live state, rebuilds the project from the savepoint's spec, and restores every volume into it. The log in the JSON tab is trimmed to the postgres lines.

rolled_back_to is the whole savepoint record, trimmed here as in step 2; restored and writable_layers are trimmed as stats was: the real result holds all three volumes and all three containers, as the summary counts them. After the rollback each container runs on the arcave/… tag of its restored layer rather than on the image its compose file names.

5. Verify​

docker compose exec -T postgres psql -U postgres -d demo -c '\d orders'
Column | Type
----------+---------
id | integer
tenant_id| integer
total | numeric

No region column.

docker compose exec -T redis redis-cli GET orders:schema_version
(nil)

The cache went back too. That is the part a pg_restore would not have given you.

6. Fix the migration and try again​

docker compose exec -T postgres psql -U postgres -d demo <<'SQL'
ALTER TABLE orders ADD COLUMN region text;
UPDATE orders SET region = 'eu'; -- all rows, not just tenant 1
ALTER TABLE orders ALTER COLUMN region SET NOT NULL;
SQL

The savepoint is still there, so a third attempt is another arcave rollback pre-migration away.

7. Clean up​

remove takes a name as well as an id. Preview first, then remove:

arcave savepoint remove pre-migration --dry-run
arcave savepoint remove pre-migration --format json
stdout (trimmed)
{
"dry_run": false,
"removed": [
{
"id": "019e843e-1650-7000-8000-000000000000",
"name": "pre-migration",
"description": "orders table, 1000 rows",
"created_at": "2026-06-01T19:41:12.123456789Z"
}
]
}

Each entry in removed is the whole savepoint record, trimmed here to its first fields.

Removing a savepoint deletes its record and its own directory; what it shared with other savepoints, and its cdc snapshots, go with arcave gc.

Tools and expertise for reproducible, production-like environments.
Copyright © 2026 Greenmask, Inc.
Privacy Policy