PostgreSQL backup tool with Point-In-Time-Recovery and restore verification
TypeScript backupbackupsdatabasedatabase-backupdevopsdockergolangkubernetesmariadbmongodbmysqlpgpostgrespostgresqls3self-hostedsystem-administrationtoolsweb-ui
1. Error output of restore tools
- 1.1 Make the MySQL restore regression test fail reliably on today's code: in
restores/usecases/mysql/restore_backup_uc_test.go, let the client stub write its error from a background process shortly after the stub itself exited, which is how a fast exit looks when the output reader is scheduled late, and confirm thatjust test-package ./internal/features/restores/usecases/mysql/...inbackend/fails with an emptystderr:before any fix. - 1.2 Switch the MySQL restore to
cmd.Stderrset to abytes.Bufferwithcmd.WaitDelay, as design decision 1 describes, and verify thatjust test-package ./internal/features/restores/usecases/mysql/...passes. - 1.3 Add the same late-writing-stub regression test to the MariaDB, MongoDB and PostgreSQL restore packages, covering both PostgreSQL restore paths, and confirm each fails on today's code. Then apply design decision 1 in
mariadb/restore_backup_uc.go,mongodb/restore_backup_uc.goandpostgresql/restore_backup_uc.go, and verify thatjust test-package ./internal/features/restores/...passes. - 1.4 Add a regression test for the PostgreSQL restore over standard input in which a
pg_restorestub writes an error and exits before reading the whole backup, and confirm it fails on today's code withfailed to stream backup data to pg_restore. Then send a non-nilwaitErrtoresolvePgRestoreOutcomebefore the copy error, as design decision 1 describes, and verify thatjust test-package ./internal/features/restores/usecases/postgresql/...passes, including the pre-existingpublicschema tests in that package.
2. Error output of dump tools and the WAL receiver
- 2.1 Add a regression test, shared through
backups/backups/core/logical/testing.gothe way the storage-timeout assertion is, in which a dump tool stub writes an error and exits before producing data. Run it for all four engines, confirm it fails on today's code, apply design decision 1 to the four logicalcreate_backup_uc.gofiles, and verify thatjust test-package ./internal/features/backups/backups/usecases/logical/...passes. - 2.2 Add a regression test in
backups/backups/usecases/physical/postgresql/in which a receiver stub writesFATAL: password authentication failedand exits at once, and assert the receiver run ends as fatal with that text in its error. Confirm it fails on today's code, apply design decision 1 toreceivewal_process.go, removenewStderrCapturefrom that file, and verify thatjust test-package ./internal/features/backups/backups/usecases/physical/postgresql/...passes.
3. Storage failure before the dump starts
- 3.1 Move
cmd.Start()beforestorage_files.StartBackgroundWritein the four logicalcreate_backup_uc.gofiles, as design decision 3 describes, and verify thatjust test-package ./internal/features/backups/backups/usecases/logical/...passes.
4. Test container readiness
- 4.1 Add a greeting-probe
wait.Strategytoutil/testing/containersand use it for the SSH bastion (SSH-2.0-) and FTP (220) next to their port waits. Verify thatjust test-package ./internal/util/testing/containers/... ./internal/features/sshtunnel/... ./internal/features/storages/...passes. - 4.2 Add a Samba readiness probe that logs in with
SambaUsernameandSambaPasswordthrough the NAS storage's SMB client library and mountsSambaShare, as design decision 2 describes, and verify thatjust test-package ./internal/util/testing/containers/... ./internal/features/storages/...passes.
5. Fixed waits in tests
- 5.1 Rewrite
Test_Run_WhenCalledTwice_Panicsintelemetry/background_service_test.goto callRunfirst with a cancelled context and drop the goroutine and the sleep, as design decision 4 describes, and verify thatjust test-package ./internal/features/telemetry/...passes. - 5.2 Rewrite the idle-timeout reader tests in
agent/verification/internal/features/api/idle_timeout_reader_test.goas design decision 4 describes, and verify thatjust --justfile agent/verification/Justfile testpasses.
6. Log order in the Docker filesystem suite
- 6.1 Send the
Databasus application exited with statusline indocker/start.shto standard error, as design decision 5 describes. Verify thatbash -n docker/start.shsucceeds and thatgit grep -n 'Databasus application exited with status' docker/start.shshows the line ending in>&2.
Change verification
just test-package ./internal/features/restores/...
just test-package ./internal/features/backups/backups/usecases/logical/...
just test-package ./internal/features/backups/backups/usecases/physical/postgresql/...
just test-package ./internal/util/testing/containers/... ./internal/features/sshtunnel/... ./internal/features/storages/...
just test-package ./internal/features/telemetry/...
just --justfile agent/verification/Justfile test