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
Restore individual tables
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

    • Export the table
    • Import the table

    Restore individual tables¶

    With Percona XtraBackup, you can export individual tables from any InnoDB database, and import them into Percona Server for MySQL with XtraDB or MySQL 5.7. The source does not need to be XtraDB or MySQL 5.7 but the destination must be. This operation only works on individual .ibd files. A table that is not contained in its own .ibd file cannot be exported.

    The following example exports and imports the following table:

    CREATE TABLE export_test (
      a int(11) DEFAULT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    

    Export the table¶

    To generate an .ibd file in the target directory, create the table using the innodb_file_per_table mode:

    $ find /data/backups/mysql/ -name export_test.*
    /data/backups/mysql/test/export_test.ibd
    

    During the --prepare step, add the --export option to the command. For example:

    $ xtrabackup --prepare --export --target-dir=/data/backups/mysql/
    

    When restoring an encrypted InnoDB tablespace table, add the keyring file:

    $ xtrabackup --prepare --export --target-dir=/tmp/table \
    --keyring-file-data=/var/lib/mysql-keyring/keyring
    

    The following files are the only files required to import the table into a server running Percona Server for MySQL with XtraDB or MySQL 5.7. If the server uses InnoDB Tablespace Encryption, add the .cfp file, which contains the transfer key and an encrypted tablespace key.

    The files are located in the target directory:

    /data/backups/mysql/test/export_test.ibd
    /data/backups/mysql/test/export_test.cfg
    

    Import the table¶

    On the destination server, create a table with the same structure, and then perform the following steps:

    1. Run the ALTER TABLE test.export_test DISCARD TABLESPACE; command. If you see the following error message:

      ERROR 1030 (HY000): Got error -1 from storage engine` message
      

      enable innodb_file_per_table option:

      $ set global innodb_file_per_table=ON;
      

      Then create the table again.

    2. Copy the exported files to the test/ subdirectory of the destination server’s data directory

    3. Execute ALTER TABLE test.export_test IMPORT TABLESPACE;

    The table should now be imported, and you should be able to SELECT from it and see the imported data.

    Note

    Persistent statistics for imported tablespace will be empty until you run the ANALYZE TABLE on the imported table. They are empty because they are stored in the system tables mysql.innodb_table_stats and mysql.innodb_index_stats and they are not updated by server during the import. This is due to upstream bug #72368.

    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.

    2023-02-23
    Percona LLC and/or its affiliates, © 2024 Cookie Preferences
    Made with Material for MkDocs