Skip to content

db: clone idle databases fast via CREATE DATABASE TEMPLATE - #72

Merged
dreispt merged 1 commit into
masterfrom
feature/db-copy-template
Oct 29, 2026
Merged

dreispt merged 1 commit into
masterfrom
feature/db-copy-template

Conversation

@dreispt

@dreispt dreispt commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • osh db copy and the missing-database copy option ([c] in osh odoo) now clone an idle source via CREATE DATABASE ... TEMPLATE — near-instant even for large databases — instead of always piping pg_dump into pg_restore
  • When the source has open connections, a prompt offers to close them for the fast clone, keep them for the slower dump/restore copy, or abort; non-interactive runs keep the connections
  • The dump/restore path streams pg_dump stdout through a host temp file into pg_restore stdin, so both halves show progress: a spinner + growing size for the dump, then the restore progress bar — and reports elapsed time when done
  • Shared the progress helpers: _stdin_progress moved from osh_backup.restore_ops into termui as stdin_progress, plus a new file_progress for unknown-total transfers and human_size/human_duration
  • The connection prompt runs before the target is dropped, so aborting leaves it untouched; copying a database onto itself is now rejected

Test plan

  • pytest tests/ — 444 passed, including new cases: open-connection close/keep/abort, non-TTY fallback, same-name guard
  • osh db copy src dst with an idle source → TEMPLATE clone
  • copy with a held psql connection → prompt → slow path with progress bars

Assisted-by: Devin:SWE-2 High

@dreispt
dreispt changed the base branch from feature/drop-compat-shims to master October 27, 2026 18:23

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔍 Devin Review: 1 flag

Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

`osh db copy` and the missing-database copy option now clone an idle
source via `CREATE DATABASE ... TEMPLATE` — near-instant even for large
databases — instead of always piping pg_dump into pg_restore.

When the source has open connections a prompt offers to close them for
the fast clone, keep them for the slower dump/restore copy, or abort;
non-interactive runs keep the connections. The dump/restore path now
streams pg_dump stdout through a host temp file into pg_restore's stdin
so both halves show progress, reusing the restore progress bar (moved
into termui as stdin_progress, joined by a file_progress spinner for the
unknown-total dump side) and reporting elapsed time when done.

The connection prompt runs before the target is dropped, so aborting
leaves it untouched; copying a database onto itself is rejected.

Assisted-by: Devin:SWE-2 High
@dreispt
dreispt force-pushed the feature/db-copy-template branch from 0395b13 to cfdb226 Compare October 27, 2026 18:51
@dreispt
dreispt merged commit 97857c2 into master Oct 29, 2026
9 checks passed
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.

1 participant