To reduce the backup size, save storage space, and speed up the backup and restore process, you can compress a backup with Percona XtraBackup. The XtraBackup --compress option makes XtraBackup compress all output data, including the transaction log file and metadata files, with one of the supported compression algorithms. To decompress all files in a backup made with the --compress option, use the --decompress option.
--compress option. The alternative compression algorithm is LZ4.
To compress files using the ZSTD compression algorithm, use the --compress option:
|
1 |
xtrabackup --backup --compress --target-dir=/data/backup |
To compress files using the LZ4 compression algorithm, set the --compress option to LZ4:
|
1 |
xtrabackup --backup --compress=lz4 --target-dir=/data/backup |
To decompress all files in a backup, use the --decompress option:
|
1 |
xtrabackup --decompress --target-dir=/data/compressed/<span style="font-weight: 400;">To </span><span style="font-weight: 400;">decompress backups taken by older versions of Percona XtraBackup that used a </span><span style="font-weight: 400;">QuickLZ</span><span style="font-weight: 400;"> compression algorithm, the </span><span style="font-weight: 400;"><code>--decompress</code></span><span style="font-weight: 400;"> option still supports </span><span style="font-weight: 400;">qpress</span><span style="font-weight: 400;"> for backward compatibility.</span> |
--compress option uses a QuickLZ compression algorithm by default. When using --compress, the resulting files have the qpress (*.qp) archive format.
To compress files using the QuickLZ compression algorithm, use the --compress option:
|
1 |
xtrabackup --backup --compress --target-dir=/data/backup<span style="font-weight: 400;">Every </span><span style="font-weight: 400;">*.qp</span><span style="font-weight: 400;"> file produced by XtraBackup is a one-file </span><span style="font-weight: 400;">qpress</span><span style="font-weight: 400;"> archive. You can extract the contents of these files with the </span><span style="font-weight: 400;"><code>--decompress</code> </span><span style="font-weight: 400;">option that supports the </span><span style="font-weight: 400;">qpress</span><span style="font-weight: 400;"> file archiver.</span> |
To compress files using the ZSTD compression algorithm, set the --compress option to zstd.
|
1 |
xtrabackup --backup --compress=zstd --target-dir=/data/backup |
The --compress=zstd option produces *.zst files. You can extract the contents of these files with the --decompress option.
Also, you can specify the ZSTD compression level with the --compress-zstd-level(=#) option as follows:
|
1 |
xtrabackup --backup --compress --compress-zstd-level=1 --target-dir=/data/backup |
Percona XtraBackup is a free, open source, complete online backup solution for all versions of Percona Server for MySQL and MySQL. It performs online non-blocking, tightly compressed, highly secure backups on transactional systems so that applications remain fully available during planned maintenance windows.