Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 42a4d72

Browse files
committed
Add root backup id for page/ptrack backups. issue #9
1 parent e972467 commit 42a4d72

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

backup.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
247247
lsn = &prev_backup->start_lsn;
248248
elog(LOG, "backup only the page that there was of the update from LSN(%X/%08X)",
249249
(uint32) (*lsn >> 32), (uint32) *lsn);
250+
251+
current.parent_backup = prev_backup->start_time;
252+
pgBackupWriteIni(&current);
250253
}
251254

252255
/* initialize backup list */

catalog.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,12 @@ pgBackupWriteResultSection(FILE *out, pgBackup *backup)
294294
fprintf(out, "STREAM=%u\n", backup->stream);
295295

296296
fprintf(out, "STATUS=%s\n", status2str(backup->status));
297+
if (backup->parent_backup != 0)
298+
{
299+
char *parent_backup = base36enc(backup->parent_backup);
300+
fprintf(out, "PARENT_BACKUP='%s'\n", parent_backup);
301+
free(parent_backup);
302+
}
297303
}
298304

299305
/* create backup.ini */
@@ -331,6 +337,7 @@ catalog_read_ini(const char *path)
331337
char *start_lsn = NULL;
332338
char *stop_lsn = NULL;
333339
char *status = NULL;
340+
char *parent_backup = NULL;
334341
int i;
335342

336343
pgut_option options[] =
@@ -349,6 +356,7 @@ catalog_read_ini(const char *path)
349356
{'u', 0, "checksum_version", NULL, SOURCE_ENV},
350357
{'u', 0, "stream", NULL, SOURCE_ENV},
351358
{'s', 0, "status", NULL, SOURCE_ENV},
359+
{'s', 0, "parent_backup", NULL, SOURCE_ENV},
352360
{0}
353361
};
354362

@@ -373,6 +381,7 @@ catalog_read_ini(const char *path)
373381
options[i++].var = &backup->checksum_version;
374382
options[i++].var = &backup->stream;
375383
options[i++].var = &status;
384+
options[i++].var = &parent_backup;
376385
Assert(i == lengthof(options) - 1);
377386

378387
pgut_readopt(path, options, ERROR);
@@ -428,6 +437,12 @@ catalog_read_ini(const char *path)
428437
free(status);
429438
}
430439

440+
if (parent_backup)
441+
{
442+
backup->parent_backup = base36dec(parent_backup);
443+
free(parent_backup);
444+
}
445+
431446
return backup;
432447
}
433448

@@ -514,4 +529,5 @@ catalog_init_config(pgBackup *backup)
514529
backup->recovery_time = (time_t) 0;
515530
backup->data_bytes = BYTES_INVALID;
516531
backup->stream = false;
532+
backup->parent_backup = 0;
517533
}

pg_probackup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ typedef struct pgBackup
138138
uint32 wal_block_size;
139139
uint32 checksum_version;
140140
bool stream;
141+
time_t parent_backup;
141142
} pgBackup;
142143

143144
typedef struct pgBackupOption

0 commit comments

Comments
 (0)