Skip to content

Backup: zip-compress output (.pgn.zip) instead of plain PGN (#91)#102

Merged
jozef2svrcek merged 1 commit into
mainfrom
compress-backup-zip
Jun 24, 2026
Merged

Backup: zip-compress output (.pgn.zip) instead of plain PGN (#91)#102
jozef2svrcek merged 1 commit into
mainfrom
compress-backup-zip

Conversation

@jozef2svrcek

Copy link
Copy Markdown
Contributor

Closes #91.

chess-db backup (and the GUI's Backup action) now writes a timestamped .pgn.zip — a single Deflate-compressed .pgn entry — instead of an uncompressed .pgn.

Why zip (and why not zstd)

Measured both on a representative ~13 MB multi-game PGN (high-entropy movetext, so a pessimistic floor):

format ratio vs zip -9
zip -9 (DEFLATE) 2.87×
zstd -3 (default) 2.72× 6% worse
zstd -19 3.54× 20% smaller

zstd only wins if cranked to a high level, and even then by ~20% — while .zip is double-clickable on every OS. For a backup artifact, native openability beats a modest size edge, so we default to zip. Both zip and zstd were already dependencies (zip is used on the import side).

Notes

  • The entry round-trips: a .pgn.zip backup re-imports through the importer's existing zip reader (a single .pgn entry inside).
  • Games are streamed straight into the archive rather than concatenated into one big in-memory String first (incidental memory win; the row load itself is still Importer: stream large PGN imports instead of loading the whole file in memory #95's concern).
  • Added a round-trip unit test (backup → open the zip → both games present); cargo test -p chess-db (14 passed) and cargo clippy -- -D warnings clean; client builds.

🤖 Generated with Claude Code

`chess-db backup` (and the GUI Backup action) now writes a timestamped
`.pgn.zip` — a single deflated `.pgn` entry — instead of an uncompressed
`.pgn`. PGN is text, so this typically shrinks backups several-fold, `.zip`
opens natively on every OS, and the entry round-trips back through the
importer's existing zip reader. Games are streamed straight into the archive
rather than concatenated into one big in-memory String first.

Adds a round-trip test (backup → read the zip → both games present) and updates
the Maintenance panel's example filename + CHANGELOG.

Closes #91.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gaUhu1KVkdxAjSJBLgbbk
@jozef2svrcek jozef2svrcek merged commit bb86029 into main Jun 24, 2026
6 checks passed
@jozef2svrcek jozef2svrcek deleted the compress-backup-zip branch June 24, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backup/export: compress output (zip/zstd) instead of plain PGN

1 participant