summaryrefslogtreecommitdiffstats
path: root/pg_restorecluster
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 12:32:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 12:32:55 +0000
commit9cc2995e4c35f593d1770c29f8e0619fc0f7a9f4 (patch)
tree617657a386230bac3fe383433eaa9bddc1ccce42 /pg_restorecluster
parentAdding upstream version 258. (diff)
downloadpostgresql-common-9cc2995e4c35f593d1770c29f8e0619fc0f7a9f4.tar.xz
postgresql-common-9cc2995e4c35f593d1770c29f8e0619fc0f7a9f4.zip
Adding upstream version 259.upstream/259
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pg_restorecluster')
-rwxr-xr-xpg_restorecluster13
1 files changed, 3 insertions, 10 deletions
diff --git a/pg_restorecluster b/pg_restorecluster
index 0a4af55..b3335ca 100755
--- a/pg_restorecluster
+++ b/pg_restorecluster
@@ -2,7 +2,7 @@
# pg_restorecluster: restore from a pg_backupcluster backup
#
-# Copyright (C) 2021 Christoph Berg <myon@debian.org>
+# Copyright (C) 2021-2024 Christoph Berg <myon@debian.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -243,13 +243,6 @@ sub restore_globals($$) {
error "psql failed" if ($?);
}
-sub create_databases($) {
- my ($backup) = @_;
-
- print "Creating databases from $backup/databases.sql ...\n";
- system_or_error "psql", "--cluster", "$version/$cluster", "-vON_ERROR_STOP=1", "-Xqf", "$backup/databases.sql";
-}
-
sub restore_dumps($) {
my ($backup) = @_;
@@ -258,7 +251,8 @@ sub restore_dumps($) {
$dump = $1; # untaint
my $db = $2;
print "Restoring $dump to database $db ...\n";
- system_or_error "pg_restore", "--cluster", "$version/$cluster", "-d", $db, $dump;
+ my @create = ($db eq "postgres" or $db eq "template1") ? () : ("--create");
+ system_or_error "pg_restore", "--cluster", "$version/$cluster", @create, "-d", "postgres", $dump;
}
}
@@ -339,7 +333,6 @@ if ($backup =~ /\.backup$/) {
start_cluster();
switch_to_cluster_owner($owneruid, $ownergid);
restore_globals($backup, $owneruid);
- create_databases($backup);
restore_dumps($backup);
analyze();
print "\n";