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
Making a 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
      • 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

    • Preparing the backup
    • Restoring the backup

    Making a Compressed Backup¶

    In order to make a compressed backup you’ll need to use innobackupex --compress

    $ innobackupex --compress /data/backup
    

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

    $ innobackupex --compress --compress-threads=4 /data/backup
    

    Output should look like this

    ...
    [01] Compressing ./imdb/comp_cast_type.ibd to /data/backup/2013-08-01_11-24-04/./imdb/comp_cast_type.ibd.qp
    [01]        ...done
    [01] Compressing ./imdb/aka_name.ibd to /data/backup/2013-08-01_11-24-04/./imdb/aka_name.ibd.qp
    [01]        ...done
    ...
    130801 11:50:24  innobackupex: completed OK
    

    Preparing the backup¶

    Before you can prepare the backup you’ll need to uncompress all the files with qpress (which is available from Percona Software repositories). You can use following one-liner to uncompress all the files:

    $ for bf in `find . -iname "*\.qp"`; do qpress -d $bf $(dirname $bf) && rm $bf; done
    

    In Percona XtraBackup 2.1.4 new innobackupex --decompress option has been implemented that can be used to decompress the backup:

    $ innobackupex --decompress /data/backup/2013-08-01_11-24-04/
    

    Note

    In order to successfully use the innobackupex --decompress option,qpress binary needs to installed and within the path. innobackupex --parallel can be used with innobackupex --decompress option to decompress multiple files simultaneously.

    When the files are uncompressed you can prepare the backup with innobackupex –apply-log:

    $ innobackupex --apply-log /data/backup/2013-08-01_11-24-04/
    

    You should check for a confirmation message:

    130802 02:51:02  innobackupex: completed OK!
    

    Now the files in /data/backups/2013-08-01_11-24-04 is ready to be used by the server.

    Note

    Percona XtraBackup doesn’t automatically remove the compressed files. In order to clean up the backup directory users should remove the \*.qp files.

    Restoring the backup¶

    Once the backup has been prepared you can use the innobackupex --copy-back to restore the backup.

    $ innobackupex --copy-back /data/backups/2013-08-01_11-24-04/
    

    This will copy the prepared data back to its original location as defined by the datadir in your my.cnf.

    After the confirmation message:

    130802 02:58:44  innobackupex: completed OK!
    

    you should check the file permissions after copying the data back. You may need to adjust them with something like:

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

    Now 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