docker-backup-database icon indicating copy to clipboard operation
docker-backup-database copied to clipboard

fix: dumper should write output to DumpName

Open trim21 opened this issue 3 months ago • 1 comments

Summary by CodeRabbit

  • New Features

    • Database dumps for MySQL and PostgreSQL are now saved directly as compressed files, avoiding stdout. This simplifies export workflows and ensures outputs are stored reliably with the expected dump filename.
  • Chores

    • Updated ignore settings to exclude IDE project files (.idea) from version control.

trim21 avatar Oct 01 '25 13:10 trim21

Walkthrough

Redirected gzip command output from standard output to a created file named by DumpName in both MySQL and PostgreSQL dump implementations. Added file creation, error handling, and deferred close. Updated .gitignore to include .idea/. No changes to exported/public APIs.

Changes

Cohort / File(s) Summary
DB dump gzip output to file
pkg/dbdump/mysql/mysql.go, pkg/dbdump/postgres/postgres.go
Create output file using DumpName, set gzipCmd.Stdout to the file instead of os.Stdout, add error handling and deferred close; keep stderr to os.Stderr and existing command pipeline unchanged.
Git ignore update
.gitignore
Added .idea/ to ignored paths.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Caller
  participant Dump as Dump.Exec
  participant DumpTool as [mysqldump/pg_dump]
  participant Gzip as gzip
  participant File as DumpName (.gz)

  Caller->>Dump: Exec()
  Dump->>DumpTool: start
  DumpTool-->>Gzip: dump stdout (pipe)
  Dump->>File: create DumpName
  Gzip-->>File: write compressed bytes (stdout redirected)
  DumpTool-->>Dump: exit
  Gzip-->>Dump: exit
  Dump-->>Caller: return
  note over Dump,Gzip: stderr remains directed to os.Stderr

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A rabbit taps keys with a gentle cheer,
“From streams to files, the bytes go here!”
Gzip now hums, a tidy tune,
DumpName cradles data soon.
.idea hops outside the repo line—
Carrots compiled, backups fine. 🥕📦

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title clearly and concisely summarizes the primary change of redirecting the dumper’s output to the DumpName file rather than stdout, matching the code modifications in both MySQL and Postgres dump implementations. It is specific to the core fix without extraneous details or generic phrasing. Its phrasing “fix: dumper should write output to DumpName” accurately reflects the developer’s intent and aligns with conventional commit syntax.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • [ ] 📝 Generate Docstrings
🧪 Generate unit tests
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Oct 01 '25 13:10 coderabbitai[bot]