Selective restoring using ndb_restore

We’ve added some new options in MySQL Cluster 6.3.22 which makes it possible to selectively restore tables. The new options for ndb_restore are:

  --include-databases=name
      Comma separated list of databases to restore.
      Example: db1,db3
  --exclude-databases=name
      Comma separated list of databases to not restore.
      Example: db1,db3
  --include-tables=name
      Comma separated list of tables to restore. Table name
      should include database name. Example: db1.t1,db3.t1
  --exclude-tables=name
      Comma separated list of tables to not restore. Table name
      should include database name. Example: db1.t1,db3.t1

To demonstrate in a few examples, lets assume you have the following tables:

 mysql> SELECT TABLE_SCHEMA AS `Schema`,TABLE_NAME AS `Table`
   FROM INFORMATION_SCHEMA.

TABLES WHERE TABLE_SCHEMA LIKE 'db_';
 +--------+-------+
 | Schema | Table |
 +--------+-------+
 | db1    | t1    |
 | db1    | t2    |
 | db1    | t3    |
 | db2    | t2    |
 | db2    | t3    |
 | db3    | t1    |
 | db3    | t4    |
 +--------+-------+

If you need to restore table db3.t4 and the complete database db2 you should do the following on all data nodes (some important options are omitted!):

 shell> ndb_restore [...] -r --include-tables=db3.t4
 shell> ndb_restore [...] -r --include-databases=db2

In a similar way you can exclude. For example, if you need to restore all database but db1:

 shell> ndb_restore [...] -r --exclude-databases=db1

To exclude the table db3.t1, and restore everything else:

 shell> ndb_restore [...] -r --exclude-tables=db3.t1

I helped making the initial patches for this feature and hope there are not to much bugs! Maybe some more suggestions on how to improve it? Of course, all this is documented in the MySQL manual.

Comments

iCafeMinds
Hi Geert can you help me out with this command?

/usr/bin/ndb_restore -b 1 n 3 --print-data --print-log --append --tab=/root/ --fields-enclosed-by=“” --fields-separated-by=“,” --lines-terminated-by=”\n”

Backup Id = 1
/usr/bin/ndb_restore: unknown variable 'fields-separated-by=,'


NDBT_ProgramExit: 2 - Wrong arguments

I just need --print-data
Geert JM Vanderkelen
The error says it all.. Check ndb_restore --help