Skip to content
Starting November 2023 Percona XtraBackup 2.4 has reached EOL status. If you have 5.7 databases, we encourage you to upgrade to 8.0 and then install Percona XtraBackup 8.0. Learn more

logo
Percona XtraBackup
Compressed Backup
Initializing search
    percona/pxb-docs
    percona/pxb-docs
    • Home
      • About Percona XtraBackup
      • How Percona XtraBackup Works
      • Understand version numbers
      • Installing Percona XtraBackup 2.4
      • Installing Percona XtraBackup on Debian and Ubuntu
      • Installing Percona XtraBackup on Red Hat Enterprise Linux and CentOS
      • Installing Percona XtraBackup from a Binary Tarball
      • Compiling and Installing from Source Code
      • Running Percona XtraBackup in a Docker container
      • Connection and Privileges Needed
      • Configuring xtrabackup
      • The Backup Cycle - Full Backups
      • Incremental Backup
      • Compressed Backup
        • Creating Compressed Backups
          • Preparing the backup
          • Restoring the backup
      • Encrypted Backup
      • Percona XtraBackup User Manual
      • Throttling Backups
      • Lockless binary log information
      • Encrypted InnoDB Tablespace Backups
      • lock-ddl-per-table Option Improvements
      • How-tos and Recipes
        • Release notes index
        • Percona XtraBackup 2.4.29 (2023-12-18)
        • Percona XtraBackup 2.4.28 (2023-04-04)
        • Percona XtraBackup 2.4.27 (2022-12-06)
        • Percona XtraBackup 2.4.26
        • Percona XtraBackup 2.4.25
        • Percona XtraBackup 2.4.24
        • Percona XtraBackup 2.4.23
        • Percona XtraBackup 2.4.22
        • Percona XtraBackup 2.4.21
        • Percona XtraBackup 2.4.20
        • Percona XtraBackup 2.4.19
        • Percona XtraBackup 2.4.18
        • Percona XtraBackup 2.4.17
        • Percona XtraBackup 2.4.16
        • Percona XtraBackup 2.4.15
        • Percona XtraBackup 2.4.14
        • Percona XtraBackup 2.4.13
        • Percona XtraBackup 2.4.12
        • Percona XtraBackup 2.4.11
        • Percona XtraBackup 2.4.10
        • Percona XtraBackup 2.4.9
        • Percona XtraBackup 2.4.8
        • Percona XtraBackup 2.4.7-2
        • Percona XtraBackup 2.4.7
        • Percona XtraBackup 2.4.6
        • Percona XtraBackup 2.4.5
        • Percona XtraBackup 2.4.4
        • Percona XtraBackup 2.4.3
        • Percona XtraBackup 2.4.2
        • Percona XtraBackup 2.4.1
      • The xtrabackup Option Reference
      • The innobackupex Option Reference
      • The xbcloud Binary
      • Exponential Backoff
      • Using the xbcloud binary with Microsoft Azure Cloud Storage
      • The xbcrypt binary
      • The xbstream binary
      • Known issues and limitations
      • Frequently Asked Questions
      • Glossary
      • Index of files created by Percona XtraBackup
      • Trademark policy
      • Copyright and licensing information
      • Version Checking

    • Creating Compressed Backups
      • Preparing the backup
      • Restoring the backup

    Compressed Backup¶

    Percona XtraBackup supports compressed backups: a local or streaming backup can be compressed or decompressed with xbstream.

    Creating Compressed Backups¶

    In order to make a compressed backup you’ll need to use the xtrabackup –compress option:

    $ xtrabackup --backup --compress --target-dir=/data/compressed/
    

    The xtrabackup --compress uses the qpress tool that you can install via the percona-release package configuration tool as follows:

    $ sudo percona-release enable tools
    $ sudo apt update
    $ sudo apt install qpress
    

    Note

    Enable the repository: percona-release enable-only tools release. If you intend to use Percona XtraBackup in combination with the upstream MySQL Server, you only need to enable the tools repository: percona-release enable-only tools.

    If you want to speed up the compression you can use the parallel compression, which can be enabled with xtrabackup –compress-threads option. Following example will use four threads for compression:

    $ xtrabackup --backup --compress --compress-threads=4 \
    --target-dir=/data/compressed/
    

    Output should look like this

    ...
    170223 13:00:38 [01] Compressing ./test/sbtest1.frm to /tmp/compressed/test/sbtest1.frm.qp
    170223 13:00:38 [01]        ...done
    170223 13:00:38 [01] Compressing ./test/sbtest2.frm to /tmp/compressed/test/sbtest2.frm.qp
    170223 13:00:38 [01]        ...done
    ...
    170223 13:00:39 [00] Compressing xtrabackup_info
    170223 13:00:39 [00]        ...done
    xtrabackup: Transaction log of lsn (9291934) to (9291934) was copied.
    170223 13:00:39 completed OK!
    

    Preparing the backup¶

    Before you can prepare the backup you must uncompress all the files. Percona XtraBackup has implemented xtrabackup --decompress option that can be used to decompress the backup.

    $ xtrabackup --decompress --target-dir=/data/compressed/
    

    Note

    xtrabackup --parallel can be used with xtrabackup --decompress option to decompress multiple files simultaneously.

    Percona XtraBackup does not automatically remove the compressed files. In order to clean up the backup directory, use the xtrabackup --remove-original option. If the files not removed they are not copied or moved to the datadir if xtrabackup --copy-back or xtrabackup --move-back are used.

    When the files are uncompressed you can prepare the backup with the xtrabackup --prepare option:

    $ xtrabackup --prepare --target-dir=/data/compressed/
    

    Check for a confirmation message:

    InnoDB: Starting shutdown...
    InnoDB: Shutdown completed; log sequence number 9293846
    170223 13:39:31 completed OK!
    

    Now the files in /data/compressed/ are ready to be used by the server.

    Restoring the backup¶

    xtrabackup has a xtrabackup --copy-back option, which performs the restoration of a backup to the server’s datadir:

    $ xtrabackup --copy-back --target-dir=/data/backups/
    

    The option copies all the data-related files back to the server’s datadir, determined by the server’s my.cnf configuration file. Check the last line of the output for a success message:

    170223 13:49:13 completed OK!
    

    Verify the file permissions after copying the data back. You may need to adjust the permissions. For example, the following command changes the owner of the file location:

    $ chown -R mysql:mysql /var/lib/mysql
    

    Now that the datadir contains the restored data. You are ready to start the server.

    Contact us

    For free technical help, visit the Percona Community Forum.

    To report bugs or submit feature requests, open a JIRA ticket.

    For paid support and managed or consulting services , contact Percona Sales.

    2022-11-10
    Percona LLC and/or its affiliates, © 2024 Cookie Preferences
    Made with Material for MkDocs