mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2026-11-06 02:57:59 +00:00
feat(backup): write database dumps gzip-compressed
Dumps stream through gzip into <db>.backup.sql.gz; no uncompressed copy touches the disk. Restore reads gzip and plain dumps by their magic bytes, verifies a gzip dump to its end before anything is dropped, and still finds the uncompressed names of older generations. The manifest names the compression. 🎯 Fix: 92 % 💥 Break: 20 % 💸 Cost: – ⏱️ Time: – 🛡️ Security: ~100 % 🏆 Score: 74 🚦 Gate: ⛔ break 20 % > 5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
328520169b
commit
b30344d494
34 files changed
+833
-110
No files matched your search
@@ -20,7 +20,7 @@ def _capture_dumps(*, db_type, rows, container, dump_tool="mariadb-dump"):
|
||||
|
||||
with (
|
||||
tempfile.TemporaryDirectory() as td,
|
||||
patch.object(db_mod, "execute_to_file", side_effect=_capture),
|
||||
patch.object(db_mod, "execute_to_gzip", side_effect=_capture),
|
||||
):
|
||||
db_mod.backup_database(
|
||||
container=container,
|
||||
@@ -94,6 +94,20 @@ class TestMariaDBDumpUsesTCP(unittest.TestCase):
|
||||
f"password reached the argv: {argv}",
|
||||
)
|
||||
|
||||
def test_every_dump_is_written_gzip_named(self):
|
||||
for db_type, container, database, suffix in (
|
||||
("postgres", "pg", "appdb", ".backup.sql.gz"),
|
||||
("mariadb", "mariadb", "appdb", ".backup.sql.gz"),
|
||||
("postgres", "pg", "*", ".cluster.backup.sql.gz"),
|
||||
):
|
||||
with self.subTest(engine=db_type, database=database):
|
||||
_argv, _env, out = _capture_dumps(
|
||||
db_type=db_type,
|
||||
rows=[(container, database, "appuser", "s3cret")],
|
||||
container=container,
|
||||
)[0]
|
||||
self.assertTrue(out.endswith(suffix), out)
|
||||
|
||||
|
||||
def dump_tool_of(argv):
|
||||
return next(arg for arg in argv if arg in ("mariadb-dump", "mysqldump"))
|
||||
|
||||
Reference in new issue
Block a user