@@ -141,7 +141,10 @@ do_restore_or_validate(time_t target_backup_id,
141
141
* we must find the first valid(!) backup.
142
142
*/
143
143
144
- if (is_restore && target_backup_id == 0 && current_backup -> status != BACKUP_STATUS_OK )
144
+ if (is_restore &&
145
+ !dest_backup &&
146
+ target_backup_id == INVALID_BACKUP_ID &&
147
+ current_backup -> status != BACKUP_STATUS_OK )
145
148
{
146
149
elog (WARNING , "Skipping backup %s, because it has non-valid status: %s" ,
147
150
base36enc (current_backup -> start_time ), status2str (current_backup -> status ));
@@ -156,9 +159,22 @@ do_restore_or_validate(time_t target_backup_id,
156
159
|| target_backup_id == INVALID_BACKUP_ID )
157
160
&& !dest_backup )
158
161
{
162
+
163
+ /* backup is not ok,
164
+ * but in case of CORRUPT, ORPHAN or DONE revalidation can be done,
165
+ * in other cases throw an error.
166
+ */
159
167
if (current_backup -> status != BACKUP_STATUS_OK )
160
- elog (ERROR , "Backup %s has status: %s" ,
161
- base36enc (current_backup -> start_time ), status2str (current_backup -> status ));
168
+ {
169
+ if (current_backup -> status == BACKUP_STATUS_DONE ||
170
+ current_backup -> status == BACKUP_STATUS_ORPHAN ||
171
+ current_backup -> status == BACKUP_STATUS_CORRUPT )
172
+ elog (WARNING , "Backup %s has status: %s" ,
173
+ base36enc (current_backup -> start_time ), status2str (current_backup -> status ));
174
+ else
175
+ elog (ERROR , "Backup %s has status: %s" ,
176
+ base36enc (current_backup -> start_time ), status2str (current_backup -> status ));
177
+ }
162
178
163
179
if (target_tli )
164
180
{
@@ -197,17 +213,24 @@ do_restore_or_validate(time_t target_backup_id,
197
213
if (current_backup -> backup_mode == BACKUP_MODE_FULL )
198
214
{
199
215
if (current_backup -> status != BACKUP_STATUS_OK )
200
- elog (ERROR , "base backup %s for given backup %s is in %s status" ,
201
- base36enc_dup (current_backup -> start_time ),
202
- base36enc_dup (dest_backup -> start_time ),
203
- status2str (current_backup -> status ));
204
- else
205
216
{
206
- /* We found both dest and base backups. */
207
- base_full_backup = current_backup ;
208
- base_full_backup_index = i ;
209
- break ;
217
+ /* Full backup revalidation can be done only for DONE and CORRUPT */
218
+ if (current_backup -> status == BACKUP_STATUS_DONE ||
219
+ current_backup -> status == BACKUP_STATUS_CORRUPT )
220
+ elog (WARNING , "base backup %s for given backup %s is in %s status, trying to revalidate" ,
221
+ base36enc_dup (current_backup -> start_time ),
222
+ base36enc_dup (dest_backup -> start_time ),
223
+ status2str (current_backup -> status ));
224
+ else
225
+ elog (ERROR , "base backup %s for given backup %s is in %s status" ,
226
+ base36enc_dup (current_backup -> start_time ),
227
+ base36enc_dup (dest_backup -> start_time ),
228
+ status2str (current_backup -> status ));
210
229
}
230
+ /* We found both dest and base backups. */
231
+ base_full_backup = current_backup ;
232
+ base_full_backup_index = i ;
233
+ break ;
211
234
}
212
235
else
213
236
/* It`s ok to skip incremental backup */
@@ -235,12 +258,16 @@ do_restore_or_validate(time_t target_backup_id,
235
258
{
236
259
pgBackup * backup = (pgBackup * ) parray_get (backups , i );
237
260
pgBackupValidate (backup );
261
+ /* Maybe we should be more paranoid and check for !BACKUP_STATUS_OK? */
238
262
if (backup -> status == BACKUP_STATUS_CORRUPT )
239
263
{
240
264
corrupted_backup = backup ;
241
265
corrupted_backup_index = i ;
242
266
break ;
243
267
}
268
+ /* We do not validate WAL files of intermediate backups
269
+ * It`s done to speed up restore
270
+ */
244
271
}
245
272
/* There is no point in wal validation
246
273
* if there is corrupted backup between base_backup and dest_backup
0 commit comments