1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-02-13 14:58:35 +02:00

add wal-size to backup.control and calculate backup size more accurately

This commit is contained in:
Anastasia 2017-06-16 12:52:27 +03:00
parent aaa894118d
commit cb1a7e3676
3 changed files with 17 additions and 3 deletions

View File

@ -374,11 +374,12 @@ do_backup_database(parray *backup_list)
{
pgFile *file = (pgFile *) parray_get(backup_files_list, i);
if (!S_ISREG(file->mode))
continue;
if (S_ISDIR(file->mode))
current.data_bytes += 4096;
/* Count the amount of the data actually copied */
current.data_bytes += file->write_size;
if (S_ISREG(file->mode))
current.data_bytes += file->write_size;
}
if (backup_files_list)
@ -482,6 +483,13 @@ do_backup(void)
do_backup_database(backup_list);
pgut_atexit_pop(backup_cleanup, NULL);
/* compute size of wal files of this backup stored in the archive */
if (!current.stream)
{
current.wal_bytes = XLOG_SEG_SIZE *
(current.stop_lsn/XLogSegSize - current.start_lsn/XLogSegSize + 1);
}
/* Backup is done. Update backup status */
current.end_time = time(NULL);
current.status = BACKUP_STATUS_DONE;

View File

@ -427,6 +427,9 @@ pgBackupWriteControl(FILE *out, pgBackup *backup)
if (backup->data_bytes != BYTES_INVALID)
fprintf(out, "data-bytes = " INT64_FORMAT "\n", backup->data_bytes);
if (backup->data_bytes != BYTES_INVALID)
fprintf(out, "wal-bytes = " INT64_FORMAT "\n", backup->wal_bytes);
fprintf(out, "status = %s\n", status2str(backup->status));
/* 'parent_backup' is set if it is incremental backup */
@ -486,6 +489,7 @@ readBackupControlFile(const char *path)
{'U', 0, "recovery-xid", &backup->recovery_xid, SOURCE_FILE_STRICT},
{'t', 0, "recovery-time", &backup->recovery_time, SOURCE_FILE_STRICT},
{'I', 0, "data-bytes", &backup->data_bytes, SOURCE_FILE_STRICT},
{'I', 0, "wal-bytes", &backup->wal_bytes, SOURCE_FILE_STRICT},
{'u', 0, "block-size", &backup->block_size, SOURCE_FILE_STRICT},
{'u', 0, "xlog-block-size", &backup->wal_block_size, SOURCE_FILE_STRICT},
{'u', 0, "checksum_version", &backup->checksum_version, SOURCE_FILE_STRICT},

View File

@ -196,6 +196,8 @@ typedef struct pgBackup
* BYTES_INVALID means nothing was backed up.
*/
int64 data_bytes;
/* Size of WAL files in archive needed to restore this backup */
int64 wal_bytes;
/* Fields needed for compatibility check */
uint32 block_size;