Skip to content

Commit

Permalink
Added new/missing parameters to pg_restore. #6562
Browse files Browse the repository at this point in the history
  • Loading branch information
akshay-joshi committed Jul 13, 2023
1 parent 8dd8d1d commit bd4e14d
Show file tree
Hide file tree
Showing 35 changed files with 376 additions and 163 deletions.
8 changes: 7 additions & 1 deletion docs/en_US/backup_dialog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ the type of statements that should be included in the backup.
position to add an IF EXISTS clause to drop databases and other objects.
This option is not valid unless *Include DROP DATABASE statement* is also set.

.. image:: images/backup_table.png
:alt: Backup dialog tables section
:align: center

Click the *Table Options* tab to continue. Use the fields in the *Table Options*
tab related to tables that should be included in the backup.
Expand Down Expand Up @@ -213,7 +216,7 @@ tab to provide other backup options.
* Move switches in the **Disable** field box to specify the type of statements
that should be excluded from the backup.

* Move the switch next to *Trigger* (active when creating a data-only backup)
* Move the switch next to *Triggers* (active when creating a data-only backup)
towards right position to include commands that will disable triggers on the
target table while the data is being loaded.

Expand All @@ -238,6 +241,9 @@ tab to provide other backup options.
position to include a statement that will use a SET SESSION AUTHORIZATION
command to determine object ownership (instead of an ALTER OWNER command).

* Use the *Exclude schema* field to not dump schemas whose name matches
pattern.

* Use the *Extra float digits* field to use the specified value when dumping
floating-point data, instead of the maximum available precision.

Expand Down
11 changes: 7 additions & 4 deletions docs/en_US/backup_server_dialog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ the type of statements that should be included in the backup.
position to add an IF EXISTS clause to drop databases and other objects.
This option is not valid unless *Include DROP DATABASE statement* is also set.

.. image:: images/backup_server_table.png
:alt: Backup dialog tables section
:align: center

Click the *Table Options* tab to continue. Use the fields in the *Table Options*
tab related to tables that should be included in the backup.
Expand Down Expand Up @@ -146,7 +149,7 @@ tab to provide other backup options.
* Move switches in the **Disable** field box to specify the type of statements
that should be excluded from the backup.

* Move the switch next to *Trigger* (active when creating a data-only backup)
* Move the switch next to *Triggers* (active when creating a data-only backup)
towards right position to include commands that will disable triggers on the
target table while the data is being loaded.

Expand All @@ -171,16 +174,16 @@ tab to provide other backup options.
position to include a statement that will use a SET SESSION AUTHORIZATION
command to determine object ownership (instead of an ALTER OWNER command).

* Use the *Exclude database* field to not dump databases whose name matches
pattern.

* Use the *Extra float digits* field to use the specified value when dumping
floating-point data, instead of the maximum available precision.

* Use the *Lock wait timeout* field to do not wait forever to acquire shared
table locks at the beginning of the dump. Instead, fail if unable to lock a
table within the specified timeout.

* Use the *Exclude database* field to not dump databases whose name matches
pattern.

When you’ve specified the details that will be incorporated into the pg_dumpall
command:

Expand Down
Binary file modified docs/en_US/images/backup_disable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/en_US/images/backup_do_not_save.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/en_US/images/backup_general.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/en_US/images/backup_miscellaneous.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/en_US/images/backup_objects.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/en_US/images/backup_queries.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/en_US/images/backup_sections.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/en_US/images/backup_server_disable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/en_US/images/backup_server_do_not_save.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/en_US/images/backup_server_general.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/en_US/images/backup_server_miscellaneous.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/en_US/images/backup_server_objects.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/en_US/images/backup_server_queries.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/en_US/images/backup_server_table.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/en_US/images/backup_table.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/en_US/images/restore_do_not_save.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/en_US/images/restore_general.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/en_US/images/restore_miscellaneous.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/en_US/images/restore_objects.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/en_US/images/restore_queries.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/en_US/images/restore_sections.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/en_US/images/restore_table.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/en_US/release_notes_7_5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ New features
| `Issue #6374 <https://github.com/pgadmin-org/pgadmin4/issues/6374>`_ - Added all supported index storage parameters while creating an index.
| `Issue #6416 <https://github.com/pgadmin-org/pgadmin4/issues/6416>`_ - Added new/missing parameters to pg_dumpall (Backup Server).
| `Issue #6417 <https://github.com/pgadmin-org/pgadmin4/issues/6417>`_ - Added new/missing parameters to pg_dump (Backup Objects).
| `Issue #6562 <https://github.com/pgadmin-org/pgadmin4/issues/6562>`_ - Added new/missing parameters to pg_restore.
Housekeeping
************
Expand Down Expand Up @@ -51,3 +52,5 @@ Bug fixes
| `Issue #6531 <https://github.com/pgadmin-org/pgadmin4/issues/6531>`_ - Fixed an issue where pgAdmin failed to setup role with hyphens in name.
| `Issue #6537 <https://github.com/pgadmin-org/pgadmin4/issues/6537>`_ - Fixed an issue where filters are not working and query history shows empty queries.
| `Issue #6544 <https://github.com/pgadmin-org/pgadmin4/issues/6544>`_ - Fix an issue where adding a sub-folder inside a folder is not working as expected in File Manager.
| `Issue #6556 <https://github.com/pgadmin-org/pgadmin4/issues/6556>`_ - Fix an error 'list' object has no attribute 'strip' while attempting to populate auto-complete manually the first time.
| `Issue #6558 <https://github.com/pgadmin-org/pgadmin4/issues/6558>`_ - Fixed an issue where ERD Tool can't load the saved pgerd file from Shared Storage.
83 changes: 60 additions & 23 deletions docs/en_US/restore_dialog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,22 @@ restore process:
* Use the drop-down listbox next to *Rolename* to specify the role that will be
used to authenticate with the server during the restore process.

Click the *Data/Objects* tab to continue. Use the fields on the *Data/Objects*
tab to specify options related to data or pgAdmin objects that correspond to
*pg_restore* options.
Click the *Data Options* tab to continue. Use the fields in the *Data Options*
tab to provide options related to data or pgAdmin objects that correspond to *pg_restore*.

.. image:: images/restore_sections.png
:alt: Restore dialog options section
:align: center

* Use the switches in the **Sections** box to specify the content that will be
* Move switches in the **Sections** field box to specify the content that will be
restored:

* Move the switch next to *Pre-data* towards right position to restore all
data definition items not included in the data or post-data item lists.

* Move the switch next to *Data* towards right position to restore actual
table data, large-object contents, and sequence values.

* Move the switch next to *Post-data* towards right position position to restore
definitions of indexes, triggers, rules, and constraints (other than
validated check constraints).
Expand All @@ -61,74 +62,107 @@ tab to specify options related to data or pgAdmin objects that correspond to
:alt: Restore dialog sections section
:align: center

* Use the switches in the **Type of objects** box to specify the objects that
* Move switches in the **Type of objects** field box to specify the objects that
will be restored:

* Move the switch next to *Only data* towards right position to limit the
restoration to data.

* Move the switch next to *Only schema* to limit the restoration to
schema-level database objects.

.. image:: images/restore_do_not_save.png
:alt: Restore dialog do not save section
:align: center

* Use the switches in the **Do not save** box to specify which objects will not
* Move switches in the **Do not save** box to specify which objects will not
be restored:

* Move the switch next to *Owner* towards right position to exclude commands
that set object ownership.
* Move the switch next to *Privilege* towards right position to exclude

* Move the switch next to *Privileges* towards right position to exclude
commands that create access privileges.
* Move the switch next to *Tablespace* towards right position to exclude

* Move the switch next to *Tablespaces* towards right position to exclude
tablespaces.

* Move the switch next to *Comments* towards right position to exclude
commands that set the comments. **Note:** This option is visible only for
database server greater than or equal to 11.

Click the *Options* tab to continue. Use these additional fields to specify
options like cleaning before restore, verbose message or using set session
authorization that correspond to *pg_restore* options.
* Move the switch next to *Publications* towards right position to exclude
publications.

* Move the switch next to *Subscriptions* towards right position to exclude
subscriptions.

* Move the switch next to *Security labels* towards right position to exclude
Security labels.

* Move the switch next to *Table access methods* towards right position to exclude
Table access methods. **Note:** This option is visible only for
database server greater than or equal to 15.

.. image:: images/restore_queries.png
:alt: Restore dialog queries section
:align: center

* Use the switches in the **Queries** box to specify the type of statements that
should be included in the restore:
Click the *Query Options* tab to continue. Use these additional fields to specify
the type of statements that should be included in the restore:


* Move the switch next to *Include CREATE DATABASE statement* towards right position
to include a command that creates a new database before performing the restore.

* Move the switch next to *Clean before restore* towards right position to
drop each existing database object (and data) before restoring.

* Move the switch next to *Include IF EXISTS clause* towards right
position to add an IF EXISTS clause to drop databases and other objects.
This option is not valid unless *Clean before restore* is also set.

* Move the switch next to *Single transaction* towards right position to
execute the restore as a single transaction (that is, wrap the emitted
commands in *BEGIN/COMMIT*). This ensures that either all the commands
complete successfully, or no changes are applied. This option implies
*--exit-on-error*.

.. image:: images/restore_disable.png
:alt: Restore dialog disable section
.. image:: images/restore_table.png
:alt: Restore dialog tables section
:align: center

* Use the switches in the **Disable** box to specify the type of statements that
should be excluded from the restore:
Click the *Table Options* tab to continue. Use the fields in the *Table Options*
tab related to tables that should be included in the backup.

* Move the switch next to *Trigger* (active when creating a data-only
restore) towards right position to include commands that will disable
triggers on the target table while the data is being loaded.
* Move the switch next to *No data for Failed Tables* towards right position
* Move the switch next to *Enable row security* towards right position to
set row_security to on instead, allowing the user to dump the parts of the
contents of the table that they have access to. This option is relevant
only when dumping the contents of a table which has row security.

* Move the switch next to *No data for failed tables* towards right position
to ignore data that fails a trigger.

Click the *Options* tab to continue. Use the fields in the *Options*
tab to provide other restore options.

.. image:: images/restore_miscellaneous.png
:alt: Restore dialog miscellaneous section
:align: center

* Use the switches in the **Miscellaneous/Behavior** box to specify
* Move switches in the **Disable** box to specify the type of statements that
should be excluded from the restore:

* Move the switch next to *Triggers* (active when creating a data-only
restore) towards right position to include commands that will disable
triggers on the target table while the data is being loaded.

* Move switches in the **Miscellaneous/Behavior** box to specify
miscellaneous restore options:

* Move the switch next to *Verbose messages* towards left to instruct
*pg_restore* to exclude verbose messages.

* Move the switch next to *Use SET SESSION AUTHORIZATION* towards right position
to include a statement that will use a SET SESSION AUTHORIZATION
command to determine object ownership (instead of an ALTER OWNER command).
Expand All @@ -138,11 +172,14 @@ authorization that correspond to *pg_restore* options.
The default is to continue and to display a count of errors at the end of
the restore.

* Use the *Exclude schema* field to not dump schemas whose name matches
pattern.

When you’ve specified the details that will be incorporated into the pg_restore
command, click the *Restore* button to start the process, or click the *Cancel*
button to exit without saving your work. A popup will confirm if the restore is
successful.

pgAdmin will run the restore process in background. You can view all the background
process with there running status and logs on the :ref:`Processes <processes>`
tab
tab
1 change: 1 addition & 0 deletions web/pgadmin/tools/backup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ def set_value(key, param, default_value=None, assertion=True):
set_param('verbose', '--verbose')
set_param('dqoute', '--quote-all-identifiers')
set_param('use_set_session_auth', '--use-set-session-authorization')
set_value('exclude_schema', '--exclude-schema')
set_value('extra_float_digits', '--extra-float-digits', None,
manager.version >= 120000)
set_value('lock_wait_timeout', '--lock-wait-timeout')
Expand Down
34 changes: 25 additions & 9 deletions web/pgadmin/tools/backup/static/js/backup.ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,21 @@ export class MiscellaneousSchema extends BaseUISchema {
disabled: false,
group: gettext('Miscellaneous'),
inlineNext: true,
}, {
id: 'exclude_schema',
label: gettext('Exclude schema'),
type: 'text',
disabled: false,
group: gettext('Miscellaneous'),
visible: isVisibleForServerBackup(obj?._top?.backupType)
}, {
id: 'exclude_database',
label: gettext('Exclude database'),
type: 'text',
disabled: false,
min_version: 160000,
group: gettext('Miscellaneous'),
visible: isVisibleForObjectBackup(obj?._top?.backupType)
}, {
id: 'extra_float_digits',
label: gettext('Extra float digits'),
Expand All @@ -392,14 +407,6 @@ export class MiscellaneousSchema extends BaseUISchema {
type: 'int',
disabled: false,
group: gettext('Miscellaneous')
}, {
id: 'exclude_database',
label: gettext('Exclude database'),
type: 'text',
disabled: false,
min_version: 160000,
group: gettext('Miscellaneous'),
visible: isVisibleForObjectBackup(obj.backupType)
}];
}
}
Expand Down Expand Up @@ -569,7 +576,7 @@ export default class BackupSchema extends BaseUISchema {
state.on_conflict_do_nothing = false;
return true;
},
inlineNext: true,
inlineNext: obj.backupType == 'server'? false : true,
}, {
id: 'include_create_database',
label: gettext('Include CREATE DATABASE statement'),
Expand Down Expand Up @@ -691,6 +698,15 @@ export default class BackupSchema extends BaseUISchema {
label: gettext('Miscellaneous'),
group: gettext('Options'),
schema: obj.getMiscellaneousSchema(),
}, {
id: 'objects',
label: gettext('objects'),
group: gettext('Objects'),
type: 'tree',
visible: () => {
return isVisibleForServerBackup(obj?.backupType);
},
tree_type: 'checkbox'
}];
}

Expand Down
25 changes: 25 additions & 0 deletions web/pgadmin/tools/backup/tests/test_backup_create_job_unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,31 @@ class BackupCreateJobTest(BaseTestGenerator):
not_expected_cmd_opts=[],
expected_exit_code=[0, None]
)),
('When backup the object with option - Exclude schema',
dict(
class_params=dict(
sid=1,
name='test_backup_server',
port=5444,
host='localhost',
database='postgres',
bfile='test_backup',
username='postgres'
),
params=dict(
file='test_backup_file',
format='custom',
verbose=True,
schemas=[],
tables=[],
database='postgres',
exclude_schema="sch*"
),
url=BACKUP_OBJECT_URL,
expected_cmd_opts=[VERBOSE, '--exclude-schema', 'sch*'],
not_expected_cmd_opts=[],
expected_exit_code=[0, None]
)),
('When backup the object with option - Extra float digits',
dict(
class_params=dict(
Expand Down
Loading

0 comments on commit bd4e14d

Please sign in to comment.