diff --git a/docs/backup-size-reporting.md b/docs/backup-size-reporting.md new file mode 100644 index 00000000..92d89c27 --- /dev/null +++ b/docs/backup-size-reporting.md @@ -0,0 +1,167 @@ +# Backup size reporting + +## Overview + +Percona XtraBackup reports the size of every successful backup in `xtrabackup_info` and reports the same values in the XtraBackup error log. + +Backup size reporting helps estimate storage requirements, check that backups work correctly, and plan restores for compressed and streamed backups. + +### Version changes + +[Percona XtraBackup 8.4.0-6](release-notes/8.4.0-6.md) introduces backup size reporting. + +## Why external tools cannot accurately measure backup size + +External tools cannot reliably determine the final size of XtraBackup output in many backup configurations. + +Backup size often differs from the MySQL datadir size because Percona XtraBackup also copies redo log data generated during the backup process. + +Several backup features further change the final output size: + +* [`--stream=xbstream`](binaries-overview.md#xbstream) adds xbstream metadata + +* [`--compress`](create-compressed-backup.md) reduces the final backup size according to data compressibility + +* Sparse InnoDB tablespaces affect filesystem size reporting + +* Streaming and cloud uploads may not produce local backup files for measurement + +* Compression, encryption, and streaming pipelines prevent external tools from accurately calculating final backup size + +Compressed backups also require sufficient free space during decompression and restore. Reporting the uncompressed backup size helps estimate restore storage requirements before recovery operations begin. + +## How backup size reporting works + +Percona XtraBackup records backup size at the end of every successful backup. Backup size reporting is enabled by default and requires no additional configuration. + +Percona XtraBackup calculates backup size after all backup operations complete, including: + +* Compression + +* Encryption + +* xbstream formatting + +* Sparse file handling + +For sparse InnoDB tablespaces, Percona XtraBackup counts only written data fragments and excludes filesystem hole ranges. + +The reported backup size matches the exact number of bytes written to the backup destination. + +Compressed backups additionally report: + +* `uncompressed_backup_size` + +* Compression ratio + +Percona XtraBackup calculates `uncompressed_backup_size` separately from the final compressed backup size so that the reported value reflects the logical backup size before compression. + +Percona XtraBackup stores the reported values in: + +* `xtrabackup_info` + +* XtraBackup error log + +### Reported values + +| Field | Description | +|---|---| +| `backup_size` | Final backup output size in bytes | +| `uncompressed_backup_size` | Total uncompressed logical backup size in bytes | +| Compression ratio | Ratio between `uncompressed_backup_size` and `backup_size` reported in the XtraBackup error log | + +### `xtrabackup_info` + +Percona XtraBackup writes backup size metadata to `xtrabackup_info` in the backup output. + +Depending on backup configuration, `xtrabackup_info` in the backup output may be: + +* Plaintext + +* Compressed + +* Encrypted + +* Embedded inside an xbstream archive + +Streamed backups store `xtrabackup_info` inside the xbstream output. + +If `xtrabackup_info` is not plaintext, you can create a separate plaintext copy of `xtrabackup_info` using the `--extra-lsndir=