Skip to content

Add PostgreSQL 18 options to the Backup and Restore dialogs#10060

Open
dpage wants to merge 1 commit into
pgadmin-org:masterfrom
dpage:feature/backup-restore-pg18-options
Open

Add PostgreSQL 18 options to the Backup and Restore dialogs#10060
dpage wants to merge 1 commit into
pgadmin-org:masterfrom
dpage:feature/backup-restore-pg18-options

Conversation

@dpage

@dpage dpage commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds the new pg_dump / pg_dumpall / pg_restore options introduced in
PostgreSQL 18 to the Backup, Backup Server and Restore dialogs.
All new options are gated to servers >= 18 (min_version: 180000 in the UI
and a manager.version >= 180000 check in the arg builders).

Backup (pg_dump for object backups, pg_dumpall for server backups)

  • Only statistics (--statistics-only) — Type of objects, mutually
    exclusive with the other Only … switches.
  • Row security policies (--no-policies), Data (--no-data),
    Schema (--no-schema) — Do not save.
  • Dump statistics (--statistics) and Sequence data
    (--sequence-data) — Miscellaneous.

Restore (pg_restore)

  • Only statistics (--statistics-only) — Type of objects, mutually
    exclusive with the other Only … switches.
  • Row security policies (--no-policies), Data (--no-data),
    Schema (--no-schema), Statistics (--no-statistics) — Do not save.

Note on options that are not included

The pg_dumpall -F/--format option (requested in #9065) and the pg_restore
--exclude-database / -g/--globals-only options (requested in #9066) are
not added: the non-text pg_dumpall feature was reverted before
PostgreSQL 18.0, and those options do not exist in the shipped 18.x client
utilities (verified against pg_dumpall --help / pg_restore --help on
18.4). The remaining, real PG 18 options from those issues are included.

Testing

  • New scenarios in the backup/restore create-job unit tests assert the new
    flags are emitted at server version >= 18 and a guard scenario asserts
    they are absent below 18.
  • pycodestyle and eslint clean; verified each flag (and combinations)
    against the bundled PostgreSQL 18.4 utilities.
  • Documentation updated for all three dialogs, plus release-notes entries.

Closes #9064
Closes #9065
Closes #9066

Summary by CodeRabbit

  • New Features

    • Added PostgreSQL 18 backup and restore options including Only Statistics, Row Security Policies exclusion, Data exclusion, Schema exclusion, Sequence Data, and Dump Statistics toggles to the Backup and Restore dialogs (available for PostgreSQL 18+).
  • Documentation

    • Updated Backup Dialog, Backup Server Dialog, and Restore Dialog documentation with descriptions of new PostgreSQL 18 options and release notes.
  • Tests

    • Added test cases to verify PostgreSQL 18 backup and restore functionality.

Adds the new pg_dump/pg_dumpall/pg_restore options introduced in
PostgreSQL 18, gated to servers >= 18:

- Only statistics (--statistics-only) in Type of objects, mutually
  exclusive with the other Only * switches.
- Row security policies (--no-policies), Data (--no-data) and
  Schema (--no-schema) in Do not save (both dialogs); Statistics
  (--no-statistics) in the Restore dialog.
- Dump statistics (--statistics) and Sequence data (--sequence-data)
  in Backup Miscellaneous.

The pg_dumpall -F/--format option and the pg_restore
--exclude-database / -g/--globals-only options are not included: the
non-text pg_dumpall feature was reverted before PostgreSQL 18.0 and
those options do not exist in the shipped 18.x client utilities.

Includes backend arg-builder wiring, unit-test scenarios and docs.

Closes pgadmin-org#9064
Closes pgadmin-org#9065
Closes pgadmin-org#9066
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

This PR adds support for PostgreSQL 18 backup and restore options to pgAdmin. New flags like --statistics-only, --no-policies, --no-data, --no-schema, --statistics, and --sequence-data are integrated into the backup dialog, backup server dialog, and restore dialog with version gating (visible only for PostgreSQL >= 18). Backend logic conditionally emits these flags, UI schemas enforce mutual exclusivity between incompatible options, and tests verify correct behavior across server versions.

Changes

PostgreSQL 18 Backup and Restore Options

Layer / File(s) Summary
Dialog and release notes documentation
docs/en_US/backup_dialog.rst, docs/en_US/backup_server_dialog.rst, docs/en_US/restore_dialog.rst, docs/en_US/release_notes_9_16.rst
Backup and restore dialog documentation is updated to describe new PostgreSQL 18 options with server version visibility (>= 18). Release notes add three new feature entries for the added pg_dump, pg_dumpall, and pg_restore options.
Backup backend logic, UI schema, and tests
web/pgadmin/tools/backup/__init__.py, web/pgadmin/tools/backup/static/js/backup.ui.js, web/pgadmin/tools/backup/tests/test_backup_create_job_unit_test.py
Backend conditionally appends --statistics-only, --no-policies, --no-data, --no-schema, --statistics, and --sequence-data flags when server version >= 180000. UI schema adds only_statistics switch with mutual exclusivity logic against other type-of-objects options, adds new do-not-save switches, and extends miscellaneous options. Tests verify flags are emitted for v18+ and suppressed for older servers, including server-backup scenarios.
Restore backend logic, UI schema, and tests
web/pgadmin/tools/restore/__init__.py, web/pgadmin/tools/restore/static/js/restore.ui.js, web/pgadmin/tools/restore/tests/test_restore_create_job_unit_test.py
Backend conditionally appends --statistics-only, --no-policies, --no-data, --no-schema, and --no-statistics flags when server version >= 180000. UI schema adds only_statistics switch with mutual exclusivity logic and expands do-not-save options. Tests verify correct flag combinations for v18+ restore operations.

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately and concisely describes the main change: adding PostgreSQL 18 options to Backup and Restore dialogs, which is the primary focus of all code changes across documentation, backend, and UI components.
Linked Issues check ✅ Passed The PR implements most requirements from #9064, #9065, and #9066 but explicitly does not implement certain options (--with-data, --with-schema, --with-statistics, -F/--format, --exclude-database, -g/--globals-only) due to feature availability constraints.
Out of Scope Changes check ✅ Passed All changes are directly related to the objective of adding PostgreSQL 18 options to Backup and Restore dialogs, covering documentation, backend implementation, UI schema, and comprehensive unit tests.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/pgadmin/tools/backup/__init__.py (1)

288-299: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Root cause: backend does not enforce one-of semantics for "Type of objects" flags.

Both arg builders can emit contradictory combinations (e.g., --data-only with --statistics-only) when payloads bypass UI constraints. Enforce exclusivity in backend command construction to keep API behavior valid and deterministic.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/pgadmin/tools/backup/__init__.py` around lines 288 - 299, The backend
currently may emit conflicting "only_*" flags; before calling set_param compute
mutually exclusive choices for only_data, only_schema, only_tablespaces,
only_roles, only_statistics (e.g., read raw booleans from data and
manager.version, then enforce one-of semantics by selecting a single true flag
according to a deterministic precedence or by refusing others), then pass those
resolved booleans to set_param; update the logic around the existing set_param
calls for only_data, only_schema, only_tablespaces, only_roles, and
only_statistics (and keep the existing manager.version check for statistics) so
only one of these flags is ever set in the constructed command.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@web/pgadmin/tools/backup/static/js/backup.ui.js`:
- Around line 166-182: The new switch with id 'only_statistics' was added but
sections that represent dump/restore sections were not wired to it, allowing
conflicting flags; update any section control definitions (the objects that have
properties 'deps' and 'disabled'—e.g., the section controls grouping under 'Type
of objects' that currently list deps like
['pre_data','data','post_data','only_data','only_schema','only_tablespaces','only_roles'])
to include 'only_statistics' in their deps arrays and add the corresponding
check in their disabled predicate (i.e., include state.only_statistics in the OR
chain used in disabled functions); make the same symmetric change in the restore
schema file where the section controls are defined so both backup and restore
honor the only_statistics switch.

---

Outside diff comments:
In `@web/pgadmin/tools/backup/__init__.py`:
- Around line 288-299: The backend currently may emit conflicting "only_*"
flags; before calling set_param compute mutually exclusive choices for
only_data, only_schema, only_tablespaces, only_roles, only_statistics (e.g.,
read raw booleans from data and manager.version, then enforce one-of semantics
by selecting a single true flag according to a deterministic precedence or by
refusing others), then pass those resolved booleans to set_param; update the
logic around the existing set_param calls for only_data, only_schema,
only_tablespaces, only_roles, and only_statistics (and keep the existing
manager.version check for statistics) so only one of these flags is ever set in
the constructed command.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 15e3abc2-446e-4e9c-bb62-b930f0b8cf5f

📥 Commits

Reviewing files that changed from the base of the PR and between 04fa05c and a8551a8.

📒 Files selected for processing (10)
  • docs/en_US/backup_dialog.rst
  • docs/en_US/backup_server_dialog.rst
  • docs/en_US/release_notes_9_16.rst
  • docs/en_US/restore_dialog.rst
  • web/pgadmin/tools/backup/__init__.py
  • web/pgadmin/tools/backup/static/js/backup.ui.js
  • web/pgadmin/tools/backup/tests/test_backup_create_job_unit_test.py
  • web/pgadmin/tools/restore/__init__.py
  • web/pgadmin/tools/restore/static/js/restore.ui.js
  • web/pgadmin/tools/restore/tests/test_restore_create_job_unit_test.py

Comment on lines +166 to +182
id: 'only_statistics',
label: gettext('Only statistics'),
type: 'switch',
group: gettext('Type of objects'),
min_version: 180000,
deps: ['pre_data', 'data', 'post_data', 'only_data', 'only_schema',
'only_tablespaces', 'only_roles'],
inlineGroup: 'type_of_objects',
disabled: function(state) {
return state.pre_data ||
state.data ||
state.post_data ||
state.only_data ||
state.only_schema ||
state.only_tablespaces ||
state.only_roles;
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Shared root cause: only_statistics was added without reciprocal section wiring.
Both backup and restore schemas add the new “Only statistics” switch, but section controls still don’t consistently depend on it. This leaves a path for conflicting --statistics-only + section flags. Fixing section deps and section disabled predicates in both files resolves both sites.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/pgadmin/tools/backup/static/js/backup.ui.js` around lines 166 - 182, The
new switch with id 'only_statistics' was added but sections that represent
dump/restore sections were not wired to it, allowing conflicting flags; update
any section control definitions (the objects that have properties 'deps' and
'disabled'—e.g., the section controls grouping under 'Type of objects' that
currently list deps like
['pre_data','data','post_data','only_data','only_schema','only_tablespaces','only_roles'])
to include 'only_statistics' in their deps arrays and add the corresponding
check in their disabled predicate (i.e., include state.only_statistics in the OR
chain used in disabled functions); make the same symmetric change in the restore
schema file where the section controls are defined so both backup and restore
honor the only_statistics switch.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds PostgreSQL 18 client-utility flags to pgAdmin’s Backup / Backup Server / Restore dialogs, updates backend argument builders to emit the new flags only for server versions >= 18, and extends documentation and unit tests accordingly.

Changes:

  • Added new PG18 switches to Backup and Restore UI schemas (Only statistics; do-not-save/do-not-restore flags; misc flags).
  • Updated backup/restore argument builders to emit the new flags when manager.version >= 180000.
  • Updated docs and release notes; expanded unit tests for new options.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
web/pgadmin/tools/restore/tests/test_restore_create_job_unit_test.py Adds a PG18 restore scenario asserting new flags are emitted.
web/pgadmin/tools/restore/static/js/restore.ui.js Adds PG18 restore UI switches (Only statistics; no-policies/no-data/no-schema/no-statistics).
web/pgadmin/tools/restore/init.py Adds PG18 restore arg-builder flags guarded by server version.
web/pgadmin/tools/backup/tests/test_backup_create_job_unit_test.py Adds PG18 backup scenarios (emit flags for >=18, guard scenario for <18).
web/pgadmin/tools/backup/static/js/backup.ui.js Adds PG18 backup UI switches (Only statistics; no-policies/no-data/no-schema; statistics/sequence-data).
web/pgadmin/tools/backup/init.py Adds PG18 backup arg-builder flags guarded by server version.
docs/en_US/restore_dialog.rst Documents new PG18 restore options.
docs/en_US/release_notes_9_16.rst Adds release note entries for issues #9064/#9065/#9066.
docs/en_US/backup_server_dialog.rst Documents new PG18 backup-server options.
docs/en_US/backup_dialog.rst Documents new PG18 backup options.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +297 to +298
set_param('only_statistics', '--statistics-only',
manager.version >= 180000)
Comment on lines +411 to +415
('When restore object with option - Do not restore Row security '
'policies, Data, Schema, Statistics and Only statistics (>= v18)',
dict(
class_params=dict(
sid=1,
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.

Add all new options present in pg_restore command Add all new options present in pg_dumpall command Add all new options present in pg_dump command

2 participants