diff --git a/src/command/backup/backup.c b/src/command/backup/backup.c index 0c47301e5..f2c31d962 100644 --- a/src/command/backup/backup.c +++ b/src/command/backup/backup.c @@ -11,7 +11,6 @@ Backup Command #include "command/archive/find.h" #include "command/backup/backup.h" #include "command/backup/common.h" -#include "command/backup/file.h" #include "command/backup/protocol.h" #include "command/check/common.h" #include "command/control/common.h" diff --git a/src/command/backup/file.c b/src/command/backup/file.c.inc similarity index 88% rename from src/command/backup/file.c rename to src/command/backup/file.c.inc index 9c2f47d6c..d7852f535 100644 --- a/src/command/backup/file.c +++ b/src/command/backup/file.c.inc @@ -1,26 +1,3 @@ -/*********************************************************************************************************************************** -Backup File -***********************************************************************************************************************************/ -#include - -#include - -#include "command/backup/blockIncr.h" -#include "command/backup/file.h" -#include "command/backup/pageChecksum.h" -#include "common/crypto/cipherBlock.h" -#include "common/crypto/hash.h" -#include "common/debug.h" -#include "common/io/bufferRead.h" -#include "common/io/filter/group.h" -#include "common/io/filter/size.h" -#include "common/io/io.h" -#include "common/log.h" -#include "common/regExp.h" -#include "common/type/convert.h" -#include "common/type/json.h" -#include "storage/helper.h" - /*********************************************************************************************************************************** Helper functions ***********************************************************************************************************************************/ @@ -35,8 +12,48 @@ segmentNumber(const String *const pgFile) FUNCTION_TEST_RETURN(UINT, regExpMatchOne(STRDEF("\\.[0-9]+$"), pgFile) ? cvtZToUInt(strrchr(strZ(pgFile), '.') + 1) : 0); } -/**********************************************************************************************************************************/ -FN_EXTERN List * +/*********************************************************************************************************************************** +Copy a file from the PostgreSQL data directory to the repository +***********************************************************************************************************************************/ +typedef struct BackupFile +{ + const String *pgFile; // Pg file to backup + bool pgFileDelta; // Checksum pg file before copying + bool pgFileIgnoreMissing; // Ignore missing pg file + uint64_t pgFileSize; // Expected pg file size + uint64_t pgFileSizeOriginal; // Original size (from manifest build) + bool pgFileCopyExactSize; // Copy only pg expected size + const Buffer *pgFileChecksum; // Expected pg file checksum + bool pgFileChecksumPage; // Validate page checksums? + bool pgFilePageHeaderCheck; // Validate page headers? + size_t blockIncrSize; // Perform block incremental on this file? + size_t blockIncrChecksumSize; // Block checksum size + uint64_t blockIncrSuperSize; // Size of the super block + const String *blockIncrMapPriorFile; // File containing prior block incremental map (NULL if none) + uint64_t blockIncrMapPriorOffset; // Offset of prior block incremental map + uint64_t blockIncrMapPriorSize; // Size of prior block incremental map + const String *manifestFile; // Repo file + const Buffer *repoFileChecksum; // Expected repo file checksum + uint64_t repoFileSize; // Expected repo file size + bool manifestFileResume; // Checksum repo file before copying + bool manifestFileHasReference; // Reference to prior backup, if any +} BackupFile; + +typedef struct BackupFileResult +{ + const String *manifestFile; // Manifest file + BackupCopyResult backupCopyResult; + bool repoInvalid; // File was recopied because repo file was invalid + uint64_t copySize; + const Buffer *copyChecksum; // Checksum of pg file + const Buffer *repoChecksum; // Checksum of repo file (including compression, etc.) + uint64_t bundleOffset; // Offset in bundle if any + uint64_t repoSize; + uint64_t blockIncrMapSize; // Size of block incremental map (0 if no map) + Pack *pageChecksumResult; +} BackupFileResult; + +static List * backupFile( const String *const repoFile, const uint64_t bundleId, const bool bundleRaw, const unsigned int blockIncrReference, const CompressType repoFileCompressType, const int repoFileCompressLevel, const CipherType cipherType, diff --git a/src/command/backup/file.h b/src/command/backup/file.h deleted file mode 100644 index b80f198d1..000000000 --- a/src/command/backup/file.h +++ /dev/null @@ -1,71 +0,0 @@ -/*********************************************************************************************************************************** -Backup File -***********************************************************************************************************************************/ -#ifndef COMMAND_BACKUP_FILE_H -#define COMMAND_BACKUP_FILE_H - -#include "common/compress/helper.h" -#include "common/crypto/common.h" -#include "common/type/keyValue.h" -#include "postgres/interface.h" - -/*********************************************************************************************************************************** -Backup file types -***********************************************************************************************************************************/ -typedef enum -{ - backupCopyResultChecksum, - backupCopyResultCopy, - backupCopyResultSkip, - backupCopyResultNoOp, - backupCopyResultTruncate, -} BackupCopyResult; - -/*********************************************************************************************************************************** -Functions -***********************************************************************************************************************************/ -// Copy a file from the PostgreSQL data directory to the repository -typedef struct BackupFile -{ - const String *pgFile; // Pg file to backup - bool pgFileDelta; // Checksum pg file before copying - bool pgFileIgnoreMissing; // Ignore missing pg file - uint64_t pgFileSize; // Expected pg file size - uint64_t pgFileSizeOriginal; // Original size (from manifest build) - bool pgFileCopyExactSize; // Copy only pg expected size - const Buffer *pgFileChecksum; // Expected pg file checksum - bool pgFileChecksumPage; // Validate page checksums? - bool pgFilePageHeaderCheck; // Validate page headers? - size_t blockIncrSize; // Perform block incremental on this file? - size_t blockIncrChecksumSize; // Block checksum size - uint64_t blockIncrSuperSize; // Size of the super block - const String *blockIncrMapPriorFile; // File containing prior block incremental map (NULL if none) - uint64_t blockIncrMapPriorOffset; // Offset of prior block incremental map - uint64_t blockIncrMapPriorSize; // Size of prior block incremental map - const String *manifestFile; // Repo file - const Buffer *repoFileChecksum; // Expected repo file checksum - uint64_t repoFileSize; // Expected repo file size - bool manifestFileResume; // Checksum repo file before copying - bool manifestFileHasReference; // Reference to prior backup, if any -} BackupFile; - -typedef struct BackupFileResult -{ - const String *manifestFile; // Manifest file - BackupCopyResult backupCopyResult; - bool repoInvalid; // File was recopied because repo file was invalid - uint64_t copySize; - const Buffer *copyChecksum; // Checksum of pg file - const Buffer *repoChecksum; // Checksum of repo file (including compression, etc.) - uint64_t bundleOffset; // Offset in bundle if any - uint64_t repoSize; - uint64_t blockIncrMapSize; // Size of block incremental map (0 if no map) - Pack *pageChecksumResult; -} BackupFileResult; - -FN_EXTERN List *backupFile( - const String *repoFile, uint64_t bundleId, bool bundleRaw, unsigned int blockIncrReference, CompressType repoFileCompressType, - int repoFileCompressLevel, CipherType cipherType, const String *cipherPass, const String *pgVersionForce, PgPageSize pageSize, - const List *fileList); - -#endif diff --git a/src/command/backup/protocol.c b/src/command/backup/protocol.c index 9ff5ed819..922c0988a 100644 --- a/src/command/backup/protocol.c +++ b/src/command/backup/protocol.c @@ -3,17 +3,25 @@ Backup Protocol Handler ***********************************************************************************************************************************/ #include -#include "command/backup/file.h" +#include "command/backup/blockIncr.h" +#include "command/backup/pageChecksum.h" #include "command/backup/protocol.h" +#include "common/compress/helper.h" +#include "common/crypto/cipherBlock.h" #include "common/crypto/hash.h" #include "common/debug.h" +#include "common/io/bufferRead.h" +#include "common/io/filter/size.h" #include "common/io/io.h" #include "common/log.h" #include "common/memContext.h" +#include "common/regExp.h" #include "common/type/json.h" #include "config/config.h" #include "storage/helper.h" +#include "command/backup/file.c.inc" + /**********************************************************************************************************************************/ FN_EXTERN ProtocolServerResult * backupFileProtocol(PackRead *const param) diff --git a/src/command/backup/protocol.h b/src/command/backup/protocol.h index 1cbdb5e4d..3f785b767 100644 --- a/src/command/backup/protocol.h +++ b/src/command/backup/protocol.h @@ -7,6 +7,18 @@ Backup Protocol Handler #include "common/type/pack.h" #include "protocol/server.h" +/*********************************************************************************************************************************** +Backup file types +***********************************************************************************************************************************/ +typedef enum +{ + backupCopyResultChecksum, + backupCopyResultCopy, + backupCopyResultSkip, + backupCopyResultNoOp, + backupCopyResultTruncate, +} BackupCopyResult; + /*********************************************************************************************************************************** Functions ***********************************************************************************************************************************/ diff --git a/src/meson.build b/src/meson.build index 7c4a51a0f..38509b9fd 100644 --- a/src/meson.build +++ b/src/meson.build @@ -138,7 +138,6 @@ src_pgbackrest = [ 'command/backup/common.c', 'command/backup/pageChecksum.c', 'command/backup/protocol.c', - 'command/backup/file.c', 'command/check/check.c', 'command/check/common.c', 'command/check/report.c', diff --git a/test/define.yaml b/test/define.yaml index f30bf8e1d..cbe61111c 100644 --- a/test/define.yaml +++ b/test/define.yaml @@ -950,7 +950,7 @@ unit: - command/backup/common - command/backup/complete.inc: included - command/backup/db.inc: included - - command/backup/file + - command/backup/file.inc: included - command/backup/incr.inc: included - command/backup/label.inc: included - command/backup/option.inc: included