To save disk space, you can compress InnoDB backup data files by
using the --compress
option of
mysqlbackup. Compression lets you keep more
sets of backup data on hand or save transmission time when
sending the backup data to another server. Also, compression
often results in faster backups because of reduced IO.
The backup compression feature works only for InnoDB tables.
After the InnoDB tablespace files are compressed during backup,
they receive the .ibz
extension. To avoid
wasting CPU cycles without saving additional disk space,
--compress
does not attempt to compress tables
that were already-compressed on the server (see
Creating Compressed Tables); nevertheless, such
tablespace files are also saved with the .ibz
extension inside the backup.
When there is unused space within an InnoDB tablespace file, the entire file is copied during an uncompressed backup. Perform a compressed backup to avoid the storage overhead for the unused space.
The binary log and relay log files are compressed and saved with
the .bz
extension when being included in a
compressed backup.
You cannot use the --compress
option
for incremental backups created only with the redo log (i.e.,
with the
--incremental-with-redo-log-only
option).
You can also select the compression algorithm to use by the
--compress-method
option and, when
using the ZLIB or LZMA compression algorithm, the level of
compression by the --compress-level
option. See Section 20.6, “Compression Options” for
details.
This is a sample command for making a compressed single-file backup:
mysqlbackup --defaults-file=/home/dbadmin/my.cnf --compress --backup-image=backup.img backup-to-image
Advanced: This is a sample command for making a compressed directory backup:
mysqlbackup --defaults-file=/home/dbadmin/my.cnf --compress-method=zlib --compress-level=5 backup
This is a sample command for making a compressed and prepared directory backup:
mysqlbackup --defaults-file=/home/dbadmin/my.cnf --compress-method=zlib --compress-level=5 backup-and-apply-log
Compression ratio is low for encrypted InnoDB tables. Creating a compressed backup with a database containing many encrypted InnoDB tables is not recommended.
See the limitation that applies to compressed backups in Appendix B, Limitations of MySQL Enterprise Backup.