PostgreSQL backup tool with Point-In-Time-Recovery and restore verification
TypeScript backupbackupsdatabasedatabase-backupdevopsdockergolangkubernetesmariadbmongodbmysqlpgpostgrespostgresqls3self-hostedsystem-administrationtoolsweb-ui
1. Backend
- 1.1 Create the migration stub with
goose -dir backend/migrations create add_postgresql_exclude_table_data sqland fill it to addexclude_table_data TEXT NOT NULL DEFAULT ''topostgresql_logical_databasesin Up and drop it in Down. AddExcludeTableData []string(json:"excludeTableData",gorm:"-") andExcludeTableDataString(columnexclude_table_data) toPostgresqlLogicalDatabase, convert them inBeforeSaveandAfterFind, assign the list inUpdateand clone it inCopyForNewDatabase. ExtendTest_UpdateDatabase_WhenExcludeTablesArePastedMultiline_StoresTrimmedUniqueNamesinbackend/internal/features/databases/controller_test.goso the data-excluded list is pasted unnormalized and read back trimmed and unique, add a controller test that creates a database with a data-excluded list, reads it back with that list, copies it and finds the list on the copy, then updates the original withoutexcludeTableDataand reads it back with an empty list, and addExcludeTableDatato the filled PostgreSQL model inbackend/internal/features/databases/model_test.goso the copy test covers it; verify withjust test-package ./internal/features/databases/...inbackend/ - 1.2 Make the dump-scope matcher agree with
pg_dumpfor unqualified entries: runRESET search_pathbefore the size and privilege queries, selectpg_catalog.pg_table_is_visible(c.oid)in both, carry it onrelationName, require it inisMatchingRelationfor a pattern without a schema part, and correct the comment atdumpscope.go:80. Add a size test inpostgresql/logical/model_test.gowherelogsis excluded and a same-named table in a second schema is still counted, and a per-version case inprivileges_test.gowherelogsis excluded and an unreadable same-named table in a second schema makes the connection test fail with its name; verify withjust test-package ./internal/features/databases/databases/postgresql/logical/...inbackend/ - 1.3 Add
ExcludeTableDataPatternstoDumpFilterwith a normalizing getter besidegetExcludeTablePatterns, passExcludeTableDatainto bothDumpFilterliterals inmodel.go, and makegetDumpedRelationsSizeBytesskip a relation matched by either list. AddTest_GetRawDbSizeMb_WhenExcludeTableDataSet_SkipsTableSizebeside the existing exclude-tables size tests inpostgresql/logical/model_test.go, asserting that the estimate drops by at least the table's total relation size, indexes included; verify withjust test-package ./internal/features/databases/databases/postgresql/logical/...inbackend/ - 1.4 Keep the privilege check skipping only whole-excluded relations, and change the missing-privileges message in
privileges.goto suggest include schemas and whole-table exclusion and to state that excluding only a table's data still requires SELECT on it. Add a per-version case inprivileges_test.gobesidetestConnectionUnreadableTableExcludedwhere the unreadable table is listed in the data-excluded list and the connection test fails with an error naming that table and mentioning the data-exclusion note; verify withjust test-package ./internal/features/databases/databases/postgresql/logical/...inbackend/ - 1.5 Append
--exclude-table-data=<entry>for every normalized entry ofExcludeTableDataafter the--exclude-tablearguments inbuildPgDumpArgs. Add a unit test increate_backup_uc_test.gothat both lists produce their flags in that order with unnormalized input trimmed and deduplicated; verify withjust test-package ./internal/features/backups/backups/usecases/logical/postgresql/...inbackend/ - 1.6 Add backup-to-restore subtests in
backend/internal/features/tests/logical/postgresql/backup_restore_test.go, run for every version likeTest_BackupAndRestorePostgresql_WithExcludeTables_ExcludedTablesNotRestored: a table listed in the data-excluded list, with rows, a primary key and a secondary index, is restored with both indexes and zero rows while a neighbour keeps its rows, and the backup's raw size leaves the emptied table out; the pattern*.history_*empties matching tables in two schemas, while the unqualifiedlogsemptiespublic.logsand leaves a same-named table in a second schema with its rows; the unqualified whole-excludedaudit_tmpremovespublic.audit_tmpand keeps a same-named table in a second schema; a partitioned table named alone in the data-excluded list is restored with its partitions' rows, and the same partitions matched by a pattern are restored empty; with the backup limited to thepublicschema, a data-excludedlogsleavespublic.logsempty and the restore has noreportingschema; a table listed in both lists is not restored at all; verify withjust test-package ./internal/features/tests/logical/postgresql/...inbackend/
2. Frontend
- 2.1 Add
excludeTableData?: string[]toPostgresqlLogicalDatabase.ts. Adddatabases.fields.excludeWholeTables,databases.fields.excludeTableData,databases.edit.postgresql.excludeTableDataTooltipanddatabases.edit.postgresql.excludeTableDataPlaceholderto all six dictionaries, and rewritedatabases.edit.postgresql.excludeTablesTooltipin all six, with the tooltip content the spec requires and each language written per the translation rules inwebsite/AGENTS.md; verify withpnpm test(the dictionary placeholder test) andpnpm typecheckinfrontend/ - 2.2 In
EditPostgreSqlLogicalSpecificDataComponent.tsx, switch the whole-table row to theexcludeWholeTableslabel, add the "Exclude table data" row directly below it with the same markup, normalization and restore-mode hiding, and includeexcludeTableDatain the condition that opens Advanced settings. AddEditPostgreSqlLogicalSpecificDataComponent.test.tsxrendering withrenderToStaticMarkup, followingEditTelegramNotifierComponent.test.tsx: a database whose only advanced value is a data-excluded table renders both labels in order with the entry, and a database with no advanced values renders neither. AddEditMySqlSpecificDataComponent.test.tsxrendering a MySQL database with an excluded table the same way and checking the label is still "Exclude tables"; verify withpnpm testinfrontend/ - 2.3 In
ShowPostgreSqlLogicalSpecificDataComponent.tsx, show the whole-table list underexcludeWholeTablesand the data-excluded list underexcludeTableDatawhen each is not empty. AddShowPostgreSqlLogicalSpecificDataComponent.test.tsxchecking that each list renders under its label when set and is absent otherwise; verify withpnpm testinfrontend/
3. Final checks
- 3.1 Run
just formatandjust lintat the repository root andpnpm buildinfrontend/, and fix every finding in the touched files; verify all three exit cleanly