@@ -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,19 @@ 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, but in case of CORRUPT, ORPHAN or DONE revalidation can be done */
159
164
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 ));
165
+ {
166
+ if (current_backup -> status == BACKUP_STATUS_DONE ||
167
+ current_backup -> status == BACKUP_STATUS_ORPHAN ||
168
+ current_backup -> status == BACKUP_STATUS_CORRUPT )
169
+ elog (WARNING , "Backup %s has status: %s" ,
170
+ base36enc (current_backup -> start_time ), status2str (current_backup -> status ));
171
+ else
172
+ elog (ERROR , "Backup %s has status: %s" ,
173
+ base36enc (current_backup -> start_time ), status2str (current_backup -> status ));
174
+ }
162
175
163
176
if (target_tli )
164
177
{
@@ -197,17 +210,24 @@ do_restore_or_validate(time_t target_backup_id,
197
210
if (current_backup -> backup_mode == BACKUP_MODE_FULL )
198
211
{
199
212
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
213
{
206
- /* We found both dest and base backups. */
207
- base_full_backup = current_backup ;
208
- base_full_backup_index = i ;
209
- break ;
214
+ /* Full backup revalidation can be done only for DONE and CORRUPT */
215
+ if (current_backup -> status == BACKUP_STATUS_DONE ||
216
+ current_backup -> status == BACKUP_STATUS_CORRUPT )
217
+ elog (WARNING , "base backup %s for given backup %s is in %s status, trying to revalidate" ,
218
+ base36enc_dup (current_backup -> start_time ),
219
+ base36enc_dup (dest_backup -> start_time ),
220
+ status2str (current_backup -> status ));
221
+ else
222
+ elog (ERROR , "base backup %s for given backup %s is in %s status" ,
223
+ base36enc_dup (current_backup -> start_time ),
224
+ base36enc_dup (dest_backup -> start_time ),
225
+ status2str (current_backup -> status ));
210
226
}
227
+ /* We found both dest and base backups. */
228
+ base_full_backup = current_backup ;
229
+ base_full_backup_index = i ;
230
+ break ;
211
231
}
212
232
else
213
233
/* It`s ok to skip incremental backup */
@@ -235,6 +255,7 @@ do_restore_or_validate(time_t target_backup_id,
235
255
{
236
256
pgBackup * backup = (pgBackup * ) parray_get (backups , i );
237
257
pgBackupValidate (backup );
258
+ /* Maybe we should be more paranoid and check for !BACKUP_STATUS_OK? */
238
259
if (backup -> status == BACKUP_STATUS_CORRUPT )
239
260
{
240
261
corrupted_backup = backup ;
0 commit comments