[GH-ISSUE #104] Restore with open database #82

Open
opened 2026-02-26 21:34:21 +03:00 by kerem · 2 comments
Owner

Originally created by @Brandejs on GitHub (Feb 24, 2025).
Original GitHub issue: https://github.com/eduardolat/pgbackweb/issues/104

Hi.

I came across your instrument and I love it. Thank you in advance for all the hard work you've done with this.

I would like to make one comment here about restoration.

If I am creating a backup of the database (including the schema). So when I perform a restore, the UI shows that the restore went fine, even though it didn't.

--data-only=no --schema-only=no --clean=yes --if-exists-no --create=yes --no-comments=yes

One of the erorr I'm struggling with is.

ERROR:  cannot drop the currently open database
STATEMENT:  DROP DATABASE IF EXISTS my_database;

This essentially makes the restore fail. And no restore will occur. But in the UI it is shown as a success.

Ideally, it would be possible to terminate the active connection before starting the recovery?
eg.

SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE pid <> pg_backend_pid();
Originally created by @Brandejs on GitHub (Feb 24, 2025). Original GitHub issue: https://github.com/eduardolat/pgbackweb/issues/104 Hi. I came across your instrument and I love it. Thank you in advance for all the hard work you've done with this. I would like to make one comment here about restoration. If I am creating a backup of the database (including the schema). So when I perform a restore, the UI shows that the restore went fine, even though it didn't. ` --data-only=no --schema-only=no --clean=yes --if-exists-no --create=yes --no-comments=yes ` One of the erorr I'm struggling with is. ``` ERROR: cannot drop the currently open database STATEMENT: DROP DATABASE IF EXISTS my_database; ``` This essentially makes the restore fail. And no restore will occur. But in the UI it is shown as a success. Ideally, it would be possible to terminate the active connection before starting the recovery? eg. ``` SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE pid <> pg_backend_pid(); ```
Author
Owner

@svenczbg commented on GitHub (Apr 12, 2025):

Restoring into an open DB can be done with the following settings.

1.) Create the dump with without "--create" flag
pg_dump 'connection-string' --blobs --clean --file dump.tar --format=tar

2.) Restore the dump with pg_restore:
pg_restore -d 'connection-string' --clean --format=tar dump.tar

<!-- gh-comment-id:2798875867 --> @svenczbg commented on GitHub (Apr 12, 2025): Restoring into an open DB can be done with the following settings. 1.) Create the dump with *without* "--create" flag `pg_dump 'connection-string' --blobs --clean --file dump.tar --format=tar` 2.) Restore the dump with pg_restore: `pg_restore -d 'connection-string' --clean --format=tar dump.tar`
Author
Owner

@MrBrax commented on GitHub (Oct 25, 2025):

so this tool is essentially useless because it can't restore a database? been trying for an hour with this tool and the dump sql file but postgres just will not accept it. nothing happens to the database when restoring

<!-- gh-comment-id:3447840004 --> @MrBrax commented on GitHub (Oct 25, 2025): so this tool is essentially useless because it can't restore a database? been trying for an hour with this tool and the dump sql file but postgres just will not accept it. nothing happens to the database when restoring
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/pgbackweb#82
No description provided.