Skip to content

Commit e71312c

Browse files
committed
add parent_backup_link to pgBackup structure. No usage for now
1 parent 6d709fb commit e71312c

File tree

5 files changed

+33
-0
lines changed

5 files changed

+33
-0
lines changed

src/catalog.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ catalog_get_backup_list(time_t requested_backup_id)
256256
parray *backups = NULL;
257257
pgBackup *backup = NULL;
258258

259+
int i;
260+
259261
/* open backup instance backups directory */
260262
date_dir = opendir(backup_instance_path);
261263
if (date_dir == NULL)
@@ -283,6 +285,7 @@ catalog_get_backup_list(time_t requested_backup_id)
283285
/* read backup information from BACKUP_CONTROL_FILE */
284286
snprintf(backup_conf_path, MAXPGPATH, "%s/%s", date_path, BACKUP_CONTROL_FILE);
285287
backup = readBackupControlFile(backup_conf_path);
288+
backup->backup_id = backup->start_time;
286289

287290
/* ignore corrupted backups */
288291
if (backup)
@@ -316,6 +319,30 @@ catalog_get_backup_list(time_t requested_backup_id)
316319

317320
parray_qsort(backups, pgBackupCompareIdDesc);
318321

322+
/* Link incremental backups with their ancestors.*/
323+
for (i = 0; i < parray_num(backups); i++)
324+
{
325+
pgBackup *curr = parray_get(backups, i);
326+
327+
int j;
328+
329+
if (curr->backup_mode == BACKUP_MODE_FULL)
330+
continue;
331+
332+
for (j = i+1; j < parray_num(backups); j++)
333+
{
334+
pgBackup *ancestor = parray_get(backups, j);
335+
336+
if (ancestor->start_time == curr->parent_backup)
337+
{
338+
curr->parent_backup_link = ancestor;
339+
/* elog(INFO, "curr %s, ancestor %s j=%d", base36enc_dup(curr->start_time),
340+
base36enc_dup(ancestor->start_time), j); */
341+
break;
342+
}
343+
}
344+
}
345+
319346
return backups;
320347

321348
err_proc:

src/pg_probackup.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ typedef struct pgBackupConfig
184184
int compress_level;
185185
} pgBackupConfig;
186186

187+
typedef struct pgBackup pgBackup;
188+
187189
/* Information about single backup stored in backup.conf */
188190
typedef struct pgBackup
189191
{
@@ -226,6 +228,7 @@ typedef struct pgBackup
226228
time_t parent_backup; /* Identifier of the previous backup.
227229
* Which is basic backup for this
228230
* incremental backup. */
231+
pgBackup *parent_backup_link;
229232
char *primary_conninfo; /* Connection parameters of the backup
230233
* in the format suitable for recovery.conf */
231234
} pgBackup;

src/restore.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ do_restore_or_validate(time_t target_backup_id,
203203
}
204204

205205
/* If we already found dest_backup, look for full backup. */
206+
/* TODO Now, as we have all backups linked, we can probably get rid of that?"*/
206207
if (dest_backup)
207208
{
208209
if (current_backup->backup_mode == BACKUP_MODE_FULL)

src/util.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ pgBackup_init(pgBackup *backup)
315315
backup->wal_block_size = XLOG_BLCKSZ;
316316
backup->stream = false;
317317
backup->parent_backup = 0;
318+
backup->parent_backup_link = NULL;
318319
backup->primary_conninfo = NULL;
319320
backup->server_version[0] = '\0';
320321
}

src/validate.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ do_validate_instance(void)
283283
elog(ERROR, "Failed to get backup list.");
284284

285285
/* Valiate each backup along with its xlog files. */
286+
/* TODO Maybe use parent_backup_link instead of looking for backups in the list */
286287
for (i = 0; i < parray_num(backups); i++)
287288
{
288289
pgBackup *base_full_backup = NULL;

0 commit comments

Comments
 (0)