pg_restore add --no-globals option when restored using pg_dumpall non-text dump

Started by Mahendra Singh Thalorabout 2 months ago3 messageshackers
Jump to latest
#1Mahendra Singh Thalor
mahi6run@gmail.com

Hi,
Recently we committed a patch to dump a full cluster with pg_dumpall in
non-text archive format and then restore using pg_restore.
Here, I am proposing a patch to add the "pg_restore --no-globals" option so
that users can skip global objects.

I made a patch for pg_restore --no-globals (only pg_restore option, not
needed with pg_dumpall as we will filter at restore end, or later we can
add for pg_dumpall also.)

*Brief*:
pg_restore: add --no-globals option to skip globals

Do not restore global objects (roles and tablespaces) and even don't
create new database if
--create or -C is not specified.
Note: database will be created only if -C is specified, otherwise
restore will be skipped for a particular database. If a db is already
created, then data of a particular db will be restored.

Please review this patch and let me know your feedback.

--
Thanks and Regards
Mahendra Singh Thalor
EnterpriseDB: http://www.enterprisedb.com

Attachments:

v01-pg_restore-add-no-globals-option-to-skip-globals.patchapplication/octet-stream; name=v01-pg_restore-add-no-globals-option-to-skip-globals.patchDownload+44-7
#2Mahendra Singh Thalor
mahi6run@gmail.com
In reply to: Mahendra Singh Thalor (#1)
Re: pg_restore add --no-globals option when restored using pg_dumpall non-text dump

On Fri, 27 Feb 2026 at 11:57, Mahendra Singh Thalor <mahi6run@gmail.com> wrote:

Hi,
Recently we committed a patch to dump a full cluster with pg_dumpall in non-text archive format and then restore using pg_restore.
Here, I am proposing a patch to add the "pg_restore --no-globals" option so that users can skip global objects.

I made a patch for pg_restore --no-globals (only pg_restore option, not needed with pg_dumpall as we will filter at restore end, or later we can add for pg_dumpall also.)

Brief:
pg_restore: add --no-globals option to skip globals

Do not restore global objects (roles and tablespaces) and even don't create new database if
--create or -C is not specified.
Note: database will be created only if -C is specified, otherwise
restore will be skipped for a particular database. If a db is already
created, then data of a particular db will be restored.

Please review this patch and let me know your feedback.

--
Thanks and Regards
Mahendra Singh Thalor
EnterpriseDB: http://www.enterprisedb.com

Here, I am attaching an updated patch.

--
Thanks and Regards
Mahendra Singh Thalor
EnterpriseDB: http://www.enterprisedb.com

Attachments:

v02-pg_restore-add-no-globals-option-to-skip-globals.patchtext/x-patch; charset=US-ASCII; name=v02-pg_restore-add-no-globals-option-to-skip-globals.patchDownload+44-7
#3Andrew Dunstan
andrew@dunslane.net
In reply to: Mahendra Singh Thalor (#2)
Re: pg_restore add --no-globals option when restored using pg_dumpall non-text dump

On 2026-02-27 Fr 2:47 AM, Mahendra Singh Thalor wrote:

On Fri, 27 Feb 2026 at 11:57, Mahendra Singh Thalor<mahi6run@gmail.com> wrote:

Hi,
Recently we committed a patch to dump a full cluster with pg_dumpall in non-text archive format and then restore using pg_restore.
Here, I am proposing a patch to add the "pg_restore --no-globals" option so that users can skip global objects.

I made a patch for pg_restore --no-globals (only pg_restore option, not needed with pg_dumpall as we will filter at restore end, or later we can add for pg_dumpall also.)

Brief:
pg_restore: add --no-globals option to skip globals

Do not restore global objects (roles and tablespaces) and even don't create new database if
--create or -C is not specified.
Note: database will be created only if -C is specified, otherwise
restore will be skipped for a particular database. If a db is already
created, then data of a particular db will be restored.

Please review this patch and let me know your feedback.

--
Thanks and Regards
Mahendra Singh Thalor
EnterpriseDB:http://www.enterprisedb.com

Here, I am attaching an updated patch.

Thanks, I have pushed a version of this.

cheers

andrew

--
Andrew Dunstan
EDB:https://www.enterprisedb.com