Skip to content

Commit be84258

Browse files
committed
PGPRO-1164: fix restore without specified backup ID
1 parent 5534b10 commit be84258

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/restore.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,18 @@ do_restore_or_validate(time_t target_backup_id,
131131
if (target_backup_id && current_backup->start_time > target_backup_id)
132132
continue;
133133

134+
/*
135+
* [PGPRO-1164] If BACKUP_ID is not provided for restore command,
136+
* we must find the first valid(!) backup.
137+
*/
138+
139+
if (is_restore && target_backup_id == 0 && current_backup->status != BACKUP_STATUS_OK)
140+
{
141+
elog(WARNING, "Skipping backup %s, because it has non-valid status: %s",
142+
base36enc(current_backup->start_time), status2str(current_backup->status));
143+
continue;
144+
}
145+
134146
/*
135147
* We found target backup. Check its status and
136148
* ensure that it satisfies recovery target.

0 commit comments

Comments
 (0)