Skip to content

Commit ed3e7a5

Browse files
committed
Small fix restore logic.
1 parent 78362a5 commit ed3e7a5

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

pg_arman.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ main(int argc, char *argv[])
176176
if(!backup_logs)
177177
pgdata_exclude[i++] = "pg_log";
178178

179+
if (target_time != NULL && target_xid != NULL)
180+
elog(ERROR, "You can't specify recovery-target-time and recovery-target-xid at the same time");
181+
179182
/* do actual operation */
180183
if (pg_strcasecmp(cmd, "init") == 0)
181184
return do_init();

restore.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ do_restore(time_t backup_id,
161161

162162
print_backup_lsn(base_backup);
163163

164+
stream_wal = base_backup->stream;
165+
164166
/* restore base backup */
165167
restore_database(base_backup);
166168

@@ -181,6 +183,9 @@ do_restore(time_t backup_id,
181183
if (backup->backup_mode == BACKUP_MODE_FULL)
182184
break;
183185

186+
if (backup_id && backup->start_time > backup_id)
187+
break;
188+
184189
/* use database backup only */
185190
if (backup->backup_mode != BACKUP_MODE_DIFF_PAGE &&
186191
backup->backup_mode != BACKUP_MODE_DIFF_PTRACK)
@@ -198,7 +203,7 @@ do_restore(time_t backup_id,
198203
last_restored_index = i;
199204
}
200205

201-
if (!stream_wal)
206+
if (!stream_wal || target_time != NULL || target_xid != NULL)
202207
for (i = last_restored_index; i >= 0; i--)
203208
{
204209
elog(LOG, "searching archived WAL...");
@@ -209,7 +214,7 @@ do_restore(time_t backup_id,
209214
}
210215

211216
/* create recovery.conf */
212-
if (!stream_wal)
217+
if (!stream_wal || target_time != NULL || target_xid != NULL)
213218
create_recovery_conf(target_time, target_xid, target_inclusive, target_tli);
214219

215220
/* release catalog lock */

0 commit comments

Comments
 (0)