Skip to content

Commit a250719

Browse files
fix: restore logical backup on pg 15.14 (#4280)
Co-authored-by: Andrew Valleteau <avallete@users.noreply.github.com>
1 parent 8b902e0 commit a250719

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

internal/db/start/start.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ EOF
160160
` + utils.Config.Db.RootKey.Value + `
161161
EOF
162162
` + utils.Config.Db.Settings.ToPostgresConfig() + `
163+
cron.launch_active_jobs = off
163164
EOF`}
164165
if !filepath.IsAbs(fromBackup) {
165166
fromBackup = filepath.Join(utils.CurrentDirAbs, fromBackup)
@@ -180,15 +181,12 @@ EOF`}
180181
if _, err := utils.DockerStart(ctx, config, hostConfig, networkingConfig, utils.DbId); err != nil {
181182
return err
182183
}
183-
if err := WaitForHealthyService(ctx, HealthTimeout, utils.DbId); err != nil {
184+
// Ignore health check because restoring a large backup may take longer than 2 minutes
185+
if err := WaitForHealthyService(ctx, HealthTimeout, utils.DbId); err != nil && len(fromBackup) == 0 {
184186
return err
185187
}
186188
// Initialize if we are on PG14 and there's no existing db volume
187-
if len(fromBackup) > 0 {
188-
if err := initSchema15(ctx, utils.DbId); err != nil {
189-
return err
190-
}
191-
} else if utils.NoBackupVolume {
189+
if utils.NoBackupVolume && len(fromBackup) == 0 {
192190
if err := SetupLocalDatabase(ctx, "", fsys, w, options...); err != nil {
193191
return err
194192
}

internal/db/start/templates/restore.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ cat "/etc/backup.sql" \
2727

2828
echo "$0: restoring schema"
2929
cat "/etc/backup.sql" \
30+
| sed -E 's/^\\(un)?restrict .*$/-- &/' \
3031
| sed -E 's/^CREATE VIEW /CREATE OR REPLACE VIEW /' \
3132
| sed -E 's/^CREATE FUNCTION /CREATE OR REPLACE FUNCTION /' \
3233
| sed -E 's/^CREATE TRIGGER /CREATE OR REPLACE TRIGGER /' \

0 commit comments

Comments
 (0)