Partitioning: Backup and Restore Table (or Repair with option use_frm).
I use data files (.MYD) to keep some big tables for archiving purpose. When I need some archive data I am using to repair the table with option “use_frm”.
mysql> REPAIR TABLE `test_table` use_frm;
I think it is the same way how native statement RESTORE TABLE works (which is is deprecated and is removed in MySQL 5.5). However, option “use_frm” works only for non partitioned tables, so if you have only .frm, .par and .MYD files the restore is not so simple.
That is my recipe (you need original DDL create fot the table to restore):
1. Get create DDL for the table;
e.g.:
mysql> CREATE TABLE IF NOT EXISTS `test_table` (
`id` int(10) unsigned NOT NULL COMMENT 'Test table',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
2. Execute it;
3. Backup it with mysqlhotcopy (my destination is /tmp);
./mysqlhotcopy -u root -p "root" --addtodest --noindices test./test_table/ /tmp
Locked 1 tables in 0 seconds.
Flushed tables (`test`.`test_table`) in 0 seconds.
Copying 6 files...
Copying indices for 4 files...
Unlocked tables.
mysqlhotcopy copied 1 tables (6 files) in 0 seconds (0 seconds overall).
4. Copy your backup files (MYD) to destination conforming to this from mysqlhotcopy (/tmp);
cp -p /backup_mysql/test/test* /tmp -v;
5. Recover indices of each partition separately with myisamchk
mysql> ./myisamchk -r "/tmp/test_table#P#p0"
mysql> ./myisamchk -r "/tmp/test_table#P#p1"
mysql> ./myisamchk -r "/tmp/test_table#P#p2"
mysql> ./myisamchk -r "/tmp/test_table#P#p3"
Your table is ready to use (you can copy it to datadir and flush tables);
No comments yet.