Importing and Exporting Individual Tables¶
In standard InnoDB, it is not normally possible to copy tables between servers by copying the files, even with innodb_file_per_table enabled. But XtraBackup allows to migrate individual table from any InnoDB database to Percona Server with XtraDB.
The table is required to be created with the option innodb_file_per_table enabled in the server, as exporting is only possible when table is stored in its own table space.
Exporting is done in the preparation stage, not at the moment of creating the backup. Once a full backup is created, prepare it with the --export option:
$ innobackupex --apply-log --export /path/to/backup
.. xtrabackup: export option is specified. xtrabackup: export metadata of table 'mydatabase/mytable' to file `./mydatabase/mytable.exp` (1 indexes) ..
Each .exp file will be used for importing that table.
To import a table to other server, first create a new table with the same structure as the one that will be imported at that server:
OTHERSERVER|mysql> CREATE TABLE mytable (...) ENGINE=InnoDB;
then discard its tablespace:
OTHERSERVER|mysql> ALTER TABLE mydatabase.mytable DISCARD TABLESPACE;
After this, copy mytable.ibd and mytable.exp files to database’s home, and import its tablespace:
OTHERSERVER|mysql> ALTER TABLE mydatabase.mytable IMPORT TABLESPACE;
Once this is executed, data in the imported table will be available.