Repository navigation
Local Docker restore testing (phase 2); release 0.2.0 - #3
Merged
Merged
Conversation
scripts/restore-test.sh restore-tests backup sets on any machine with Docker, never on the cluster: for each target it starts a throwaway scratch server matching the recorded server version (postgres:<major>, mariadb:<major.minor>, mongo:<major.minor> as a single-node replica set) in its own compose project, restores the set into it, checks the result, and removes everything. Backups are mounted read-only and read as their owner; scratch data can live in RAM (--tmpfs); --keep leaves a scratch server up for inspection; scratch startup is retried, since MariaDB's first boot can overrun its entrypoint's limit on busy hosts. New subcommands, needing no config file: - dbbackup inspect PATH: describe a set (text, json, or shell-quoted env). - dbbackup restore-test PATH: verify, restore into a scratch server, and compare it with the set's inventory. Missing databases, objects, users or roles are errors; row-count differences are warnings. Row counts: the restored side is always counted exactly. InnoDB's TABLE_ROWS estimate can be off by orders of magnitude, so it's no longer recorded; Aria/MyISAM counts, pg reltuples and Mongo's metadata counts still are. The new exact_counts option records COUNT(*)s at backup time for exact comparison. 0.1.x MariaDB sets have their counts skipped. make restore-test-check (also in CI) backs up the compose stack and runs the script against the result. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 2: restore testing that runs on a workstation with Docker, never on the cluster.
scripts/restore-test.sh /mnt/db-backups # the latest set of every target scripts/restore-test.sh --set 20261009T021500Z /mnt/db-backups mariadb-mainFor each target, the script:
postgres:<major>,mariadb:<major.minor>, ormongo:<major.minor>as a single-node replica set, so--oplogReplaybehaves as in production). Each one gets its own compose project and network, with no host ports.The host needs nothing but Docker. Backups are mounted read-only and read as the backup root's owner, because
pg_dump's directory archives are mode 0700.Options:
--set,--image,--build(build from the checkout),--tmpfs(scratch data in RAM),--keep(leave the scratch server up). TheSCRATCH_IMAGE_*variables override the scratch images, e.g. to rehearse an upgrade.New subcommands (no config file needed)
dbbackup inspect PATH [--format text|env|json]describes a set. The script uses theenvformat to choose the scratch image.dbbackup restore-test PATH --host … | --uri-env …verifies the set, restores it, and compares it with the inventory:Row counts
The first runs showed InnoDB's
TABLE_ROWSestimates on freshly loaded tables as 41 and 0 for tables holding 3,000 and 500 rows. Warnings built on those would be misleading, so:pg_class.reltuplesand Mongo's metadata counts are still recorded, and compared within a tolerance (25%, and at least 100 rows).exact_counts(in defaults or per target, off by default) recordsCOUNT(*)for every table at backup time, compared exactly. It scans every table nightly, hence off by default.Also
make restore-test-checkbacks up the compose stack and runs the script on the result. CI now runs it after the integration suite.newTagand the docs' image references are bumped.Test plan
make lint;make test: 93 unit tests, including inventory comparison, exact vs estimated vs legacy counts,open_set,inspectenv quoting, and theexact_countsconfigmake integration: 17 end-to-end tests, now also asserting exact MariaDB counts (3000 / 500) and thecountsmode in manifestsmake restore-test-check: all four targets PASSED, with no warningsERROR (no usable set)and exits 1🤖 Generated with Claude Code