feat(backup): overhaul backup/restore — per-dialect clients, driver-based Redis/ClickHouse, bug fixes - #41
Open
paulocastellano wants to merge 8 commits into
Open
feat(backup): overhaul backup/restore — per-dialect clients, driver-based Redis/ClickHouse, bug fixes#41paulocastellano wants to merge 8 commits into
paulocastellano wants to merge 8 commits into
Conversation
…) with 3 deliberate improvements
…ased Redis/ClickHouse, fixes Refactor the monolithic 1436-line backup.ts into a Beekeeper-style architecture and fix the long-standing runtime bugs, verified end-to-end against real databases. Architecture (Phases 1-2): - Extract helpers into focused modules (process-args, ssl-temp, archive, BinaryFinder, models) - BaseCommandClient + one client per dialect under backup-clients/ and restore-clients/, wired by commandClientsFor(); backup.ts now only orchestrates - Extract splitSqlStatements to a pure util (decouple service from the IPC layer) Bug fixes (Phases 3, 5): - Redis: unrestorable --rdb replaced with driver-based SCAN/DUMP/RESTORE + TTL - ClickHouse: works over SSH (HTTP driver) and now exports data, not DDL-only - MongoDB: multiple collections backed up per-collection, never a silent full-db dump; add --authenticationDatabase to match the driver - Delete partial artifacts on cancel/error; keep log head+tail instead of tail-only Options & performance (Phase 4): - PostgreSQL format: plain / custom (-Fc) / directory (-Fd) with parallel jobs and pg_restore-based restore (format auto-detected by PGDMP magic / directory) - MySQL default charset utf8mb4 and PostgreSQL encoding UTF8 so emoji/multibyte survive UI (Phase 6): - StepExecute rebuilt around progress (raw command/log moved behind "Technical details") - StepConfigure exposes format / encoding / charset / parallel-jobs Tests: - Per-client unit tests; Docker round-trip integration tests for Redis, ClickHouse, PostgreSQL (plain/custom/directory) and MongoDB, all asserting emoji/multibyte integrity - Fix pre-existing utils.test.ts navigator stub; fix backup-restore integration credentials
- Fix incomplete escaping in clickhouse-serializer (escape backslash before quote, matching the driver's escapeValue) to prevent SETTINGS string break-out - Replace relative ../ imports with @main/ aliases across backup/ (CLAUDE.md rule) - Introduce PgDumpFormat enum instead of string literals for the pg_dump format - Add unit tests for the two untested paths: partial-artifact cleanup on failure, and the driver-based Redis backup (no spawned binary)
Behavior-preserving deduplication (all tests stay green): - getStringOption + maskFlagValue helpers in process-args; use across MySQL/PG clients - appendMongoTlsArgs helper in ssl-temp; replaces the duplicated Mongo TLS block in the Mongo backup and restore clients - Collapse runRestore's three near-identical stdin-piping branches into one pipeStdin decision + a shared attachInputStream helper
…uard, types) - Driver-based dialects (Redis/ClickHouse) now show "runs over the connection" in the command preview instead of a misleading CLI command — and no longer surface the binary client's ClickHouse-over-SSH error in the preview (the driver path works over SSH). Implemented at the IPC layer (driverPreviewSpec) so the service stays fully unit-tested. - Relax binaryPath validation to allow empty for driver dialects; execute handlers still require a binary for binary-based dialects. - Replace `as any` on Redis zadd with an explicit variadic signature. - Add requireOrSkip db-guard: integration tests FAIL instead of silently skipping when REQUIRE_DB_TESTS=1, preventing false-green CI without Docker. Applied to the round-trips. - Add unit test for appendMongoTlsArgs (cert+key PEM concat + temp-file tracking).
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.
Resumo
Reescreve o sistema de backup/restore que era frágil ("dava vários paus"): o
src/main/services/backup.tsmonolítico (1436 linhas) virou uma arquitetura modular espelhando o Beekeeper Studio (1 cliente por dialeto), e os 5 bugs de runtime foram corrigidos — verificados end-to-end contra bancos reais via Docker.backup.ts: 1436 → ~590 linhas.Bugs corrigidos (verificados contra containers)
--rdb(não restaurável via--pipe) → driverSCAN/DUMP/RESTORE+ TTL, funciona por SSH.INSERTs viaFORMAT SQLInsert).mongodump -cpor collection (sem dump silencioso do banco inteiro);--authenticationDatabasealinhado ao driver.utf8mb4(MySQL) eUTF8(PostgreSQL) para preservar emoji/multibyte.Arquitetura
BaseCommandClient+ clientes por dialeto embackup-clients/erestore-clients/, via factorycommandClientsFor().plain/custom (-Fc)/directory (-Fd -j)com restore viapg_restore(formato auto-detectado pelo magicPGDMP/ diretório).splitSqlStatementsextraído para@main/utils/sql(desacopla serviço da camada IPC).Testes
extraCommands, caminho driver, limpeza de parcial).Code review
Passou por code review (8 ângulos): 1 bug real (escaping ClickHouse) corrigido, convenções alinhadas (imports
@main/, enumPgDumpFormat), lacunas de teste cobertas.Notas / limitações conhecidas
🤖 Generated with Claude Code