- backup/restore mysql InnoDB tables in an easy way
pip install ibdx
or
pipx install ibdx (recommended)
git clone https://github.com/Grvzard/ibdx.git
cd ibdx
pip install .
ibdx --help
Take care: There seems to be an incompatibility between mysql and mariadb. Make sure that ibdx works between the same db system.
Let's say we have following tables:
[ logs_2023_01, logs_2023_02, logs_2023_03, logs_2023_04 ]
ibdx backup -u user -p password -h localhost --db test1 --tables logs_2023_% -f logs.2023.zip [--datadir /mysql/datadir]
ibdx restore -f logs.2023.zip -u user -p password -h localhost --db test1 --tables logs_2023_% [--datadir /mysql/datadir]
When the mysql server is running in Docker, the --datadir option is required.
backup:
- mysql>
FLUSH TABLES test1 FOR EXPORT;
(tables are read locked) - backup the .ibd (and .cfg) files.
- mysql>
UNLOCK TABLES;
restore:
- (optional) mysql>
CREATE TABLE test1;
- mysql>
ALTER TABLE test1 DISCARD TABLESPACE;
- copy the .ibd (and .cfg) files to the mysql-server's datadir
- mysql>
ALTER TABLE test1 IMPORT TABLESPACE;