Skip to content

Support streaming PostgreSQL dump and restore - #52

Open
davenquinn with Copilot wants to merge 3 commits into
mainfrom
copilot/add-cli-dump-and-restore
Open

Support streaming PostgreSQL dump and restore#52
davenquinn with Copilot wants to merge 3 commits into
mainfrom
copilot/add-cli-dump-and-restore

Conversation

Copilot AI commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Database transfer handlers could not safely stream binary dumps through standard I/O, preventing CLI-level dump/restore pipelines.

  • Stream-aware transfer handlers

    • Treat None as inherited stdout for dumps and stdin for restores.
    • Preserve binary output without routing dump data through text logging.
  • Basic transfer CLI

    • Add database-transfer with dump and restore commands.
    • Map - to stdout/stdin and support repeated -n/--schema dump filters.
database-transfer --database "$SOURCE_DATABASE" dump -n temp - \
  | database-transfer --database "$TARGET_DATABASE" restore -
  • Coverage
    • Add focused tests for handler stream routing and CLI argument translation.

Copilot AI linked an issue Sep 3, 2026 that may be closed by this pull request
Co-authored-by: davenquinn <1537910+davenquinn@users.noreply.github.com>
Copilot AI changed the title [WIP] Add CLI for Postgres dump and restore to stdout Support streaming PostgreSQL dump and restore Sep 3, 2026
Copilot AI requested a review from davenquinn September 3, 2026 04:56

@davenquinn davenquinn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check that this actually works with print_stdout

database-transfer --database "$SOURCE_DATABASE" dump -n temp - \
| database-transfer --database "$TARGET_DATABASE" restore -
"""

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this CLI to the testing area, and convert it to Typer (fitting with Macrostrat's standard practice).

asyncio.create_task(print_stream_progress(proc.stderr, None)),
)
async def _monitor_stderr(proc):
await asyncio.gather(print_stdout(proc.stderr), proc.wait())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check that the print_stdout function actually works for this. I think it is geared to printing for user consumption.

Co-authored-by: davenquinn <1537910+davenquinn@users.noreply.github.com>

Copilot AI commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Please check that this actually works with print_stdout

print_stdout writes through Rich's default stdout console, so it would corrupt a dump pipeline. Commit 0318fd4 replaces it on inherited-stream paths with a binary-safe print_stderr; the focused test verifies diagnostics leave stdout untouched.

Copilot AI requested a review from davenquinn September 3, 2026 05:30
@davenquinn
davenquinn marked this pull request as ready for review September 3, 2026 07:21
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.

Postgres dump and restore to stdout

2 participants