diff options
| author | Robert Haas | 2023-12-20 14:49:12 +0000 |
|---|---|---|
| committer | Robert Haas | 2023-12-20 14:49:12 +0000 |
| commit | dc212340058b4e7ecfc5a7a81ec50e7a207bf288 (patch) | |
| tree | 79ffec15f6a8d9fce1333b99dd0b587e2459d38f /src/include/backup | |
| parent | 174c480508ac25568561443e6d4a82d5c1103487 (diff) | |
Add support for incremental backup.
To take an incremental backup, you use the new replication command
UPLOAD_MANIFEST to upload the manifest for the prior backup. This
prior backup could either be a full backup or another incremental
backup. You then use BASE_BACKUP with the INCREMENTAL option to take
the backup. pg_basebackup now has an --incremental=PATH_TO_MANIFEST
option to trigger this behavior.
An incremental backup is like a regular full backup except that
some relation files are replaced with files with names like
INCREMENTAL.${ORIGINAL_NAME}, and the backup_label file contains
additional lines identifying it as an incremental backup. The new
pg_combinebackup tool can be used to reconstruct a data directory
from a full backup and a series of incremental backups.
Patch by me. Reviewed by Matthias van de Meent, Dilip Kumar, Jakub
Wartak, Peter Eisentraut, and Álvaro Herrera. Thanks especially to
Jakub for incredibly helpful and extensive testing.
Discussion: http://postgr.es/m/CA+TgmoYOYZfMCyOXFyC-P+-mdrZqm5pP2N7S-r0z3_402h9rsA@mail.gmail.com
Diffstat (limited to 'src/include/backup')
| -rw-r--r-- | src/include/backup/basebackup.h | 5 | ||||
| -rw-r--r-- | src/include/backup/basebackup_incremental.h | 55 |
2 files changed, 59 insertions, 1 deletions
diff --git a/src/include/backup/basebackup.h b/src/include/backup/basebackup.h index 1432d9c206b..345bd22534c 100644 --- a/src/include/backup/basebackup.h +++ b/src/include/backup/basebackup.h @@ -34,6 +34,9 @@ typedef struct int64 size; /* total size as sent; -1 if not known */ } tablespaceinfo; -extern void SendBaseBackup(BaseBackupCmd *cmd); +struct IncrementalBackupInfo; + +extern void SendBaseBackup(BaseBackupCmd *cmd, + struct IncrementalBackupInfo *ib); #endif /* _BASEBACKUP_H */ diff --git a/src/include/backup/basebackup_incremental.h b/src/include/backup/basebackup_incremental.h new file mode 100644 index 00000000000..de99117599e --- /dev/null +++ b/src/include/backup/basebackup_incremental.h @@ -0,0 +1,55 @@ +/*------------------------------------------------------------------------- + * + * basebackup_incremental.h + * API for incremental backup support + * + * Portions Copyright (c) 2010-2022, PostgreSQL Global Development Group + * + * src/include/backup/basebackup_incremental.h + * + *------------------------------------------------------------------------- + */ +#ifndef BASEBACKUP_INCREMENTAL_H +#define BASEBACKUP_INCREMENTAL_H + +#include "access/xlogbackup.h" +#include "common/relpath.h" +#include "storage/block.h" +#include "utils/palloc.h" + +#define INCREMENTAL_MAGIC 0xd3ae1f0d + +typedef enum +{ + BACK_UP_FILE_FULLY, + BACK_UP_FILE_INCREMENTALLY +} FileBackupMethod; + +struct IncrementalBackupInfo; +typedef struct IncrementalBackupInfo IncrementalBackupInfo; + +extern IncrementalBackupInfo *CreateIncrementalBackupInfo(MemoryContext); + +extern void AppendIncrementalManifestData(IncrementalBackupInfo *ib, + const char *data, + int len); +extern void FinalizeIncrementalManifest(IncrementalBackupInfo *ib); + +extern void PrepareForIncrementalBackup(IncrementalBackupInfo *ib, + BackupState *backup_state); + +extern char *GetIncrementalFilePath(Oid dboid, Oid spcoid, + RelFileNumber relfilenumber, + ForkNumber forknum, unsigned segno); +extern FileBackupMethod GetFileBackupMethod(IncrementalBackupInfo *ib, + const char *path, + Oid dboid, Oid spcoid, + RelFileNumber relfilenumber, + ForkNumber forknum, + unsigned segno, size_t size, + unsigned *num_blocks_required, + BlockNumber *relative_block_numbers, + unsigned *truncation_block_length); +extern size_t GetIncrementalFileSize(unsigned num_blocks_required); + +#endif |
