Skip to content

Commit b4e0eae

Browse files
author
Aleksandr Parfenov
committed
Show corrupted backups in list
1 parent eb6ebd9 commit b4e0eae

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

src/catalog.c

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -283,20 +283,28 @@ catalog_get_backup_list(time_t requested_backup_id)
283283
/* read backup information from BACKUP_CONTROL_FILE */
284284
snprintf(backup_conf_path, MAXPGPATH, "%s/%s", data_path, BACKUP_CONTROL_FILE);
285285
backup = readBackupControlFile(backup_conf_path);
286-
backup->backup_id = backup->start_time;
287286

288-
/* ignore corrupted backups */
289-
if (backup)
287+
if (!backup)
290288
{
291-
if (requested_backup_id != INVALID_BACKUP_ID
292-
&& requested_backup_id != backup->start_time)
293-
{
294-
pgBackupFree(backup);
295-
continue;
296-
}
297-
parray_append(backups, backup);
298-
backup = NULL;
289+
backup = pgut_new(pgBackup);
290+
pgBackupInit(backup);
291+
backup->start_time = base36dec(data_ent->d_name);
292+
}
293+
else if (strcmp(base36enc(backup->start_time), data_ent->d_name) != 0)
294+
{
295+
elog(WARNING, "backup ID in control file \"%s\" doesn't match name of the backup folder \"%s\"",
296+
base36enc(backup->start_time), backup_conf_path);
297+
}
298+
299+
backup->backup_id = backup->start_time;
300+
if (requested_backup_id != INVALID_BACKUP_ID
301+
&& requested_backup_id != backup->start_time)
302+
{
303+
pgBackupFree(backup);
304+
continue;
299305
}
306+
parray_append(backups, backup);
307+
backup = NULL;
300308

301309
if (errno && errno != ENOENT)
302310
{

0 commit comments

Comments
 (0)