Documentation Home
MySQL 9.0 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 40.0Mb
PDF (A4) - 40.1Mb
Man Pages (TGZ) - 259.0Kb
Man Pages (Zip) - 366.2Kb
Info (Gzip) - 4.0Mb
Info (Zip) - 4.0Mb


MySQL 9.0 Reference Manual  / ...  / MySQL NDB Cluster 9.0  / NDB Cluster Programs  /  ndb_restore — Restore an NDB Cluster Backup

25.5.23 ndb_restore — Restore an NDB Cluster Backup

The NDB Cluster restoration program is implemented as a separate command-line utilityndb_restore, which can normally be found in the MySQLbin directory. This program reads the files created as a result of the backup and inserts the stored information into the database.

ndb_restore must be executed once for each of the backup files that were created by theSTART BACKUP command used to create the backup (seeSection 25.6.8.2, “Using The NDB Cluster Management Client to Create a Backup”). This is equal to the number of data nodes in the cluster at the time that the backup was created.

Note

Before usingndb_restore, it is recommended that the cluster be running in single user mode, unless you are restoring multiple data nodes in parallel. SeeSection 25.6.6, “NDB Cluster Single User Mode”, for more information.

Options that can be used withndb_restore are shown in the following table. Additional descriptions follow the table.

  • --allow-pk-changes

    Command-Line Format--allow-pk-changes[=0|1]
    TypeInteger
    Default Value0
    Minimum Value0
    Maximum Value1

    When this option is set to1,ndb_restore allows the primary keys in a table definition to differ from that of the same table in the backup. This may be desirable when backing up and restoring between different schema versions with primary key changes on one or more tables, and it appears that performing the restore operation using ndb_restore is simpler or more efficient than issuing manyALTER TABLE statements after restoring table schemas and data.

    The following changes in primary key definitions are supported by--allow-pk-changes:

    • Extending the primary key: A non-nullable column that exists in the table schema in the backup becomes part of the table's primary key in the database.

      Important

      When extending a table's primary key, any columns which become part of primary key must not be updated while the backup is being taken; any such updates discovered byndb_restore cause the restore operation to fail, even when no change in value takes place. In some cases, it may be possible to override this behavior using the--ignore-extended-pk-updates option; see the description of this option for more information.

    • Contracting the primary key (1): A column that is already part of the table's primary key in the backup schema is no longer part of the primary key, but remains in the table.

    • Contracting the primary key (2): A column that is already part of the table's primary key in the backup schema is removed from the table entirely.

    These differences can be combined with other schema differences supported byndb_restore, including changes to blob and text columns requiring the use of staging tables.

    Basic steps in a typical scenario using primary key schema changes are listed here:

    1. Restore table schemas usingndb_restore--restore-meta

    2. Alter schema to that desired, or create it

    3. Back up the desired schema

    4. Runndb_restore--disable-indexes using the backup from the previous step, to drop indexes and constraints

    5. Runndb_restore--allow-pk-changes (possibly along with--ignore-extended-pk-updates,--disable-indexes, and possibly other options as needed) to restore all data

    6. Runndb_restore--rebuild-indexes using the backup made with the desired schema, to rebuild indexes and constraints

    When extending the primary key, it may be necessary forndb_restore to use a temporary secondary unique index during the restore operation to map from the old primary key to the new one. Such an index is created only when necessary to apply events from the backup log to a table which has an extended primary key. This index is namedNDB$RESTORE_PK_MAPPING, and is created on each table requiring it; it can be shared, if necessary, by multiple instances ofndb_restore instances running in parallel. (Runningndb_restore--rebuild-indexes at the end of the restore process causes this index to be dropped.)

  • --append

    Command-Line Format--append

    When used with the--tab and--print-data options, this causes the data to be appended to any existing files having the same names.

  • --backup-path=dir_name

    Command-Line Format--backup-path=path
    TypeDirectory name
    Default Value./

    The path to the backup directory is required; this is supplied tondb_restore using the--backup-path option, and must include the subdirectory corresponding to the ID backup of the backup to be restored. For example, if the data node'sDataDir is/var/lib/mysql-cluster, then the backup directory is/var/lib/mysql-cluster/BACKUP, and the backup files for the backup with the ID 3 can be found in/var/lib/mysql-cluster/BACKUP/BACKUP-3. The path may be absolute or relative to the directory in which thendb_restore executable is located, and may be optionally prefixed withbackup-path=.

    It is possible to restore a backup to a database with a different configuration than it was created from. For example, suppose that a backup with backup ID12, created in a cluster with two storage nodes having the node IDs2 and3, is to be restored to a cluster with four nodes. Thenndb_restore must be run twice—once for each storage node in the cluster where the backup was taken. However,ndb_restore cannot always restore backups made from a cluster running one version of MySQL to a cluster running a different MySQL version. SeeSection 25.3.7, “Upgrading and Downgrading NDB Cluster”, for more information.

    Important

    It is not possible to restore a backup made from a newer version of NDB Cluster using an older version ofndb_restore. You can restore a backup made from a newer version of MySQL to an older cluster, but you must use a copy ofndb_restore from the newer NDB Cluster version to do so.

    For example, to restore a cluster backup taken from a cluster running NDB Cluster 8.4.0 to a cluster running NDB Cluster 8.0.38, you must use thendb_restore that comes with the NDB Cluster 8.0.38 distribution.

    For more rapid restoration, the data may be restored in parallel, provided that there is a sufficient number of cluster connections available. That is, when restoring to multiple nodes in parallel, you must have an[api] or[mysqld] section in the clusterconfig.ini file available for each concurrentndb_restore process. However, the data files must always be applied before the logs.

  • --backup-password=password

    Command-Line Format--backup-password=password
    TypeString
    Default Value[none]

    This option specifies a password to be used when decrypting an encrypted backup with the--decrypt option. This must be the same password that was used to encrypt the backup.

    The password must be 1 to 256 characters in length, and must be enclosed by single or double quotation marks. It can contain any of the ASCII characters having character codes 32, 35, 38, 40-91, 93, 95, and 97-126; in other words, it can use any printable ASCII characters except for!,',",$,%,\, and^.

    It is possible to omit the password, in which casendb_restore waits for it to be supplied fromstdin, as when using--backup-password-from-stdin.

  • --backup-password-from-stdin[=TRUE|FALSE]

    Command-Line Format--backup-password-from-stdin

    When used in place of--backup-password, this option enables input of the backup password from the system shell (stdin), similar to how this is done when supplying the password interactively tomysql when using the--password without supplying the password on the command line.

  • --backupid=#,-b

    Command-Line Format--backupid=#
    TypeNumeric
    Default Valuenone

    This option is required; it is used to specify the ID or sequence number of the backup, and is the same number shown by the management client in theBackupbackup_id completed message displayed upon completion of a backup. (SeeSection 25.6.8.2, “Using The NDB Cluster Management Client to Create a Backup”.)

    Important

    When restoring cluster backups, you must be sure to restore all data nodes from backups having the same backup ID. Using files from different backups results at best in restoring the cluster to an inconsistent state, and is likely to fail altogether.

  • --character-sets-dir

    Command-Line Format--character-sets-dir=path

    Directory containing character sets.

  • --connect,-c

    Command-Line Format--connect=connection_string
    TypeString
    Default Valuelocalhost:1186

    Alias for--ndb-connectstring.

  • --connect-retries

    Command-Line Format--connect-retries=#
    TypeInteger
    Default Value12
    Minimum Value0
    Maximum Value12

    Number of times to retry connection before giving up.

  • --connect-retry-delay

    Command-Line Format--connect-retry-delay=#
    TypeInteger
    Default Value5
    Minimum Value0
    Maximum Value5

    Number of seconds to wait between attempts to contact management server.

  • --connect-string

    Command-Line Format--connect-string=connection_string
    TypeString
    Default Value[none]

    Same as--ndb-connectstring.

  • --core-file

    Command-Line Format--core-file

    Write core file on error; used in debugging.

  • --decrypt

    Command-Line Format--decrypt

    Decrypt an encrypted backup using the password supplied by the--backup-password option.

  • --defaults-extra-file

    Command-Line Format--defaults-extra-file=path
    TypeString
    Default Value[none]

    Read given file after global files are read.

  • --defaults-file

    Command-Line Format--defaults-file=path
    TypeString
    Default Value[none]

    Read default options from given file only.

  • --defaults-group-suffix

    Command-Line Format--defaults-group-suffix=string
    TypeString
    Default Value[none]

    Also read groups with concat(group, suffix).

  • --disable-indexes

    Command-Line Format--disable-indexes

    Disable restoration of indexes during restoration of the data from a nativeNDB backup. Afterwards, you can restore indexes for all tables at once with multithreaded building of indexes using--rebuild-indexes, which should be faster than rebuilding indexes concurrently for very large tables.

    This option also drops any foreign keys specified in the backup.

    MySQL can open anNDB table for which one or more indexes cannot be found, provided the query does not use any of the affected indexes; otherwise the query is rejected withER_NOT_KEYFILE. In the latter case, you can temporarily work around the problem by executing anALTER TABLE statement such as this one:

    ALTER TABLE tbl ALTER INDEX idx INVISIBLE;

    This causes MySQL to ignore the indexidx on tabletbl. SeePrimary Keys and Indexes, for more information, as well asSection 10.3.12, “Invisible Indexes”.

  • --dont-ignore-systab-0,-f

    Command-Line Format--dont-ignore-systab-0

    Normally, when restoring table data and metadata,ndb_restore ignores the copy of theNDB system table that is present in the backup.--dont-ignore-systab-0 causes the system table to be restored.This option is intended for experimental and development use only, and is not recommended in a production environment.

  • --exclude-databases=db-list

    Command-Line Format--exclude-databases=list
    TypeString
    Default Value

    Comma-delimited list of one or more databases which should not be restored.

    This option is often used in combination with--exclude-tables; see that option's description for further information and examples.

  • --exclude-intermediate-sql-tables[=TRUE|FALSE]

    Command-Line Format--exclude-intermediate-sql-tables[=TRUE|FALSE]
    TypeBoolean
    Default ValueTRUE

    When performing copyingALTER TABLE operations,mysqld creates intermediate tables (whose names are prefixed with#sql-). WhenTRUE, the--exclude-intermediate-sql-tables option keepsndb_restore from restoring such tables that may have been left over from these operations. This option isTRUE by default.

  • --exclude-missing-columns

    Command-Line Format--exclude-missing-columns

    It is possible to restore only selected table columns using this option, which causesndb_restore to ignore any columns missing from tables being restored as compared to the versions of those tables found in the backup. This option applies to all tables being restored. If you wish to apply this option only to selected tables or databases, you can use it in combination with one or more of the--include-* or--exclude-* options described elsewhere in this section to do so, then restore data to the remaining tables using a complementary set of these options.

  • --exclude-missing-tables

    Command-Line Format--exclude-missing-tables

    It is possible to restore only selected tables using this option, which causesndb_restore to ignore any tables from the backup that are not found in the target database.

  • --exclude-tables=table-list

    Command-Line Format--exclude-tables=list
    TypeString
    Default Value

    List of one or more tables to exclude; each table reference must include the database name. Often used together with--exclude-databases.

    When--exclude-databases or--exclude-tables is used, only those databases or tables named by the option are excluded; all other databases and tables are restored byndb_restore.

    This table shows several invocations ofndb_restore using--exclude-* options (other options possibly required have been omitted for clarity), and the effects these options have on restoring from an NDB Cluster backup:

    Table 25.23 Several invocations of ndb_restore using --exclude-* options, and the effects these options have on restoring from anNDB Cluster backup.

    OptionResult
    --exclude-databases=db1All tables in all databases exceptdb1 are restored; no tables indb1 are restored
    --exclude-databases=db1,db2 (or--exclude-databases=db1--exclude-databases=db2)All tables in all databases exceptdb1 anddb2 are restored; no tables indb1 ordb2 are restored
    --exclude-tables=db1.t1All tables exceptt1 in databasedb1 are restored; all other tables indb1 are restored; all tables in all other databases are restored
    --exclude-tables=db1.t2,db2.t1 (or--exclude-tables=db1.t2--exclude-tables=db2.t1)All tables in databasedb1 except fort2 and all tables in databasedb2 except for tablet1 are restored; no other tables indb1 ordb2 are restored; all tables in all other databases are restored

    You can use these two options together. For example, the following causes all tables in all databasesexcept for databasesdb1 anddb2, and tablest1 andt2 in databasedb3, to be restored:

    $> ndb_restore [...] --exclude-databases=db1,db2 --exclude-tables=db3.t1,db3.t2

    (Again, we have omitted other possibly necessary options in the interest of clarity and brevity from the example just shown.)

    You can use--include-* and--exclude-* options together, subject to the following rules:

    • The actions of all--include-* and--exclude-* options are cumulative.

    • All--include-* and--exclude-* options are evaluated in the order passed to ndb_restore, from right to left.

    • In the event of conflicting options, the first (rightmost) option takes precedence. In other words, the first option (going from right to left) that matches against a given database or tablewins.

    For example, the following set of options causesndb_restore to restore all tables from databasedb1 exceptdb1.t1, while restoring no other tables from any other databases:

    --include-databases=db1 --exclude-tables=db1.t1

    However, reversing the order of the options just given simply causes all tables from databasedb1 to be restored (includingdb1.t1, but no tables from any other database), because the--include-databases option, being farthest to the right, is the first match against databasedb1 and thus takes precedence over any other option that matchesdb1 or any tables indb1:

    --exclude-tables=db1.t1 --include-databases=db1
  • --fields-enclosed-by=char

    Command-Line Format--fields-enclosed-by=char
    TypeString
    Default Value

    Each column value is enclosed by the string passed to this option (regardless of data type; see the description of--fields-optionally-enclosed-by).

  • --fields-optionally-enclosed-by

    Command-Line Format--fields-optionally-enclosed-by
    TypeString
    Default Value

    The string passed to this option is used to enclose column values containing character data (such asCHAR,VARCHAR,BINARY,TEXT, orENUM).

  • --fields-terminated-by=char

    Command-Line Format--fields-terminated-by=char
    TypeString
    Default Value\t (tab)

    The string passed to this option is used to separate column values. The default value is a tab character (\t).

  • --help

    Command-Line Format--help

    Display help text and exit.

  • --hex

    Command-Line Format--hex

    If this option is used, all binary values are output in hexadecimal format.

  • --ignore-extended-pk-updates

    Command-Line Format--ignore-extended-pk-updates[=0|1]
    TypeInteger
    Default Value0
    Minimum Value0
    Maximum Value1

    When using--allow-pk-changes, columns which become part of a table's primary key must not be updated while the backup is being taken; such columns should keep the same values from the time values are inserted into them until the rows containing the values are deleted. Ifndb_restore encounters updates to these columns when restoring a backup, the restore fails. Because some applications may set values for all columns when updating a row, even when some column values are not changed, the backup may include log events appearing to update columns which are not in fact modified. In such cases you can set--ignore-extended-pk-updates to1, forcingndb_restore to ignore such updates.

    Important

    When causing these updates to be ignored, the user is responsible for ensuring that there are no updates to the values of any columns that become part of the primary key.

    For more information, see the description of--allow-pk-changes.

  • --include-databases=db-list

    Command-Line Format--include-databases=list
    TypeString
    Default Value

    Comma-delimited list of one or more databases to restore. Often used together with--include-tables; see the description of that option for further information and examples.

  • --include-stored-grants

    Command-Line Format--include-stored-grants

    ndb_restore does not by default restore shared users and grants (seeSection 25.6.13, “Privilege Synchronization and NDB_STORED_USER”) to thendb_sql_metadata table. Specifying this option causes it to do so.

  • --include-tables=table-list

    Command-Line Format--include-tables=list
    TypeString
    Default Value

    Comma-delimited list of tables to restore; each table reference must include the database name.

    When--include-databases or--include-tables is used, only those databases or tables named by the option are restored; all other databases and tables are excluded byndb_restore, and are not restored.

    The following table shows several invocations ofndb_restore using--include-* options (other options possibly required have been omitted for clarity), and the effects these have on restoring from an NDB Cluster backup:

    Table 25.24 Several invocations of ndb_restore using --include-* options, and their effects on restoring from an NDB Clusterbackup.

    OptionResult
    --include-databases=db1Only tables in databasedb1 are restored; all tables in all other databases are ignored
    --include-databases=db1,db2 (or--include-databases=db1--include-databases=db2)Only tables in databasesdb1 anddb2 are restored; all tables in all other databases are ignored
    --include-tables=db1.t1Only tablet1 in databasedb1 is restored; no other tables indb1 or in any other database are restored
    --include-tables=db1.t2,db2.t1 (or--include-tables=db1.t2--include-tables=db2.t1)Only the tablet2 in databasedb1 and the tablet1 in databasedb2 are restored; no other tables indb1,db2, or any other database are restored

    You can also use these two options together. For example, the following causes all tables in databasesdb1 anddb2, together with the tablest1 andt2 in databasedb3, to be restored (and no other databases or tables):

    $> ndb_restore [...] --include-databases=db1,db2 --include-tables=db3.t1,db3.t2

    (Again we have omitted other, possibly required, options in the example just shown.)

    It also possible to restore only selected databases, or selected tables from a single database, without any--include-* (or--exclude-*) options, using the syntax shown here:

    ndb_restoreother_optionsdb_name,[db_name[,...] |tbl_name[,tbl_name][,...]]

    In other words, you can specify either of the following to be restored:

    • All tables from one or more databases

    • One or more tables from a single database

  • --lines-terminated-by=char

    Command-Line Format--lines-terminated-by=char
    TypeString
    Default Value\n (linebreak)

    Specifies the string used to end each line of output. The default is a linefeed character (\n).

  • --login-path

    Command-Line Format--login-path=path
    TypeString
    Default Value[none]

    Read given path from login file.

  • --no-login-paths

    Command-Line Format--no-login-paths

    Skips reading options from the login path file.

  • --lossy-conversions,-L

    Command-Line Format--lossy-conversions

    This option is intended to complement the--promote-attributes option. Using--lossy-conversions allows lossy conversions of column values (type demotions or changes in sign) when restoring data from backup. With some exceptions, the rules governing demotion are the same as for MySQL replication; seeSection 19.5.1.9.2, “Replication of Columns Having Different Data Types”, for information about specific type conversions currently supported by attribute demotion.

    This option also makes it possible to restore aNULL column asNOT NULL. The column must not contain anyNULL entries; otherwisendb_restore stops with an error.

    ndb_restore reports any truncation of data that it performs during lossy conversions once per attribute and column.

  • --no-binlog

    Command-Line Format--no-binlog

    This option prevents any connected SQL nodes from writing data restored byndb_restore to their binary logs.

  • --no-restore-disk-objects,-d

    Command-Line Format--no-restore-disk-objects

    This option stopsndb_restore from restoring any NDB Cluster Disk Data objects, such as tablespaces and log file groups; seeSection 25.6.11, “NDB Cluster Disk Data Tables”, for more information about these.

  • --no-upgrade,-u

    Command-Line Format--no-upgrade

    When usingndb_restore to restore a backup,VARCHAR columns created using the old fixed format are resized and recreated using the variable-width format now employed. This behavior can be overridden by specifying--no-upgrade.

  • --ndb-connectstring

    Command-Line Format--ndb-connectstring=connection_string
    TypeString
    Default Value[none]

    Set connection string for connecting tondb_mgmd. Syntax:[nodeid=id;][host=]hostname[:port]. Overrides entries inNDB_CONNECTSTRING andmy.cnf.

  • --ndb-mgm-tls

    Command-Line Format--ndb-mgm-tls=level
    TypeEnumeration
    Default Valuerelaxed
    Valid Values

    relaxed

    strict

    Sets the level of TLS support required to connect to the management server; one ofrelaxed orstrict.relaxed (the default) means that a TLS connection is attempted, but success is not required;strict means that TLS is required to connect.

  • --ndb-mgmd-host

    Command-Line Format--ndb-mgmd-host=connection_string
    TypeString
    Default Value[none]

    Same as--ndb-connectstring.

  • --ndb-nodegroup-map=map,-z

    Command-Line Format--ndb-nodegroup-map=map

    Any value set for this option is ignored, and the option itself does nothing.

  • --ndb-nodeid

    Command-Line Format--ndb-nodeid=#
    TypeInteger
    Default Value[none]

    Set node ID for this node, overriding any ID set by--ndb-connectstring.

  • --ndb-optimized-node-selection

    Command-Line Format--ndb-optimized-node-selection

    Enable optimizations for selection of nodes for transactions. Enabled by default; use--skip-ndb-optimized-node-selection to disable.

  • --ndb-tls-search-path

    Command-Line Format--ndb-tls-search-path=list
    TypePath name
    Default Value (Unix)$HOME/ndb-tls
    Default Value (Windows)$HOMEDIR/ndb-tls

    Specify a list of directories to search for a CA file. On Unix platforms, the directory names are separated by colons (:); on Windows systems, the semicolon character (;) is used as the separator. A directory reference may be relative or absolute; it may contain one or more environment variables, each denoted by a prefixed dollar sign ($), and expanded prior to use.

    Searching begins with the leftmost named directory and proceeds from left to right until a file is found. An empty string denotes an empty search path, which causes all searches to fail. A string consisting of a single dot (.) indicates that the search path limited to the current working directory.

    If no search path is supplied, the compiled-in default value is used. This value depends on the platform used: On Windows, this is\ndb-tls; on other platforms (including Linux), it is$HOME/ndb-tls. This can be overridden by compiling NDB Cluster using-DWITH_NDB_TLS_SEARCH_PATH.

  • --no-defaults

    Command-Line Format--no-defaults

    Do not read default options from any option file other than login file.

  • --nodeid=#,-n

    Command-Line Format--nodeid=#
    TypeNumeric
    Default Valuenone

    Specify the node ID of the data node on which the backup was taken; required.

    When restoring to a cluster with different number of data nodes from that where the backup was taken, this information helps identify the correct set or sets of files to be restored to a given node. (In such cases, multiple files usually need to be restored to a single data node.) SeeRestoring to a different number of data nodes, for additional information and examples.

  • --num-slices=#

    Command-Line Format--num-slices=#
    TypeInteger
    Default Value1
    Minimum Value1
    Maximum Value1024

    When restoring a backup by slices, this option sets the number of slices into which to divide the backup. This allows multiple instances ofndb_restore to restore disjoint subsets in parallel, potentially reducing the amount of time required to perform the restore operation.

    Aslice is a subset of the data in a given backup; that is, it is a set of fragments having the same slice ID, specified using the--slice-id option. The two options must always be used together, and the value set by--slice-id must always be less than the number of slices.

    ndb_restore encounters fragments and assigns each one a fragment counter. When restoring by slices, a slice ID is assigned to each fragment; this slice ID is in the range 0 to 1 less than the number of slices. For a table that is not aBLOB table, the slice to which a given fragment belongs is determined using the formula shown here:

    [slice_ID] = [fragment_counter] % [number_of_slices]

    For aBLOB table, a fragment counter is not used; the fragment number is used instead, along with the ID of the main table for theBLOB table (recall thatNDB storesBLOB values in a separate table internally). In this case, the slice ID for a given fragment is calculated as shown here:

    [slice_ID] =([main_table_ID] + [fragment_ID]) % [number_of_slices]

    Thus, restoring byN slices means runningN instances ofndb_restore, all with--num-slices=N (along with any other necessary options) and one each with--slice-id=1,--slice-id=2,--slice-id=3, and so on throughslice-id=N-1.

    Example.  Assume that you want to restore a backup namedBACKUP-1, found in the default directory/var/lib/mysql-cluster/BACKUP/BACKUP-3 on the node file system on each data node, to a cluster with four data nodes having the node IDs 1, 2, 3, and 4. To perform this operation using five slices, execute the sets of commands shown in the following list:

    1. Restore the cluster metadata usingndb_restore as shown here:

      $> ndb_restore -b 1 -n 1 -m --disable-indexes --backup-path=/home/ndbuser/backups
    2. Restore the cluster data to the data nodes invokingndb_restore as shown here:

      $> ndb_restore -b 1 -n 1 -r --num-slices=5 --slice-id=0 --backup-path=/var/lib/mysql-cluster/BACKUP/BACKUP-1$> ndb_restore -b 1 -n 1 -r --num-slices=5 --slice-id=1 --backup-path=/var/lib/mysql-cluster/BACKUP/BACKUP-1$> ndb_restore -b 1 -n 1 -r --num-slices=5 --slice-id=2 --backup-path=/var/lib/mysql-cluster/BACKUP/BACKUP-1$> ndb_restore -b 1 -n 1 -r --num-slices=5 --slice-id=3 --backup-path=/var/lib/mysql-cluster/BACKUP/BACKUP-1$> ndb_restore -b 1 -n 1 -r --num-slices=5 --slice-id=4 --backup-path=/var/lib/mysql-cluster/BACKUP/BACKUP-1$> ndb_restore -b 1 -n 2 -r --num-slices=5 --slice-id=0 --backup-path=/var/lib/mysql-cluster/BACKUP/BACKUP-1$> ndb_restore -b 1 -n 2 -r --num-slices=5 --slice-id=1 --backup-path=/var/lib/mysql-cluster/BACKUP/BACKUP-1$> ndb_restore -b 1 -n 2 -r --num-slices=5 --slice-id=2 --backup-path=/var/lib/mysql-cluster/BACKUP/BACKUP-1$> ndb_restore -b 1 -n 2 -r --num-slices=5 --slice-id=3 --backup-path=/var/lib/mysql-cluster/BACKUP/BACKUP-1$> ndb_restore -b 1 -n 2 -r --num-slices=5 --slice-id=4 --backup-path=/var/lib/mysql-cluster/BACKUP/BACKUP-1$> ndb_restore -b 1 -n 3 -r --num-slices=5 --slice-id=0 --backup-path=/var/lib/mysql-cluster/BACKUP/BACKUP-1$> ndb_restore -b 1 -n 3 -r --num-slices=5 --slice-id=1 --backup-path=/var/lib/mysql-cluster/BACKUP/BACKUP-1$> ndb_restore -b 1 -n 3 -r --num-slices=5 --slice-id=2 --backup-path=/var/lib/mysql-cluster/BACKUP/BACKUP-1$> ndb_restore -b 1 -n 3 -r --num-slices=5 --slice-id=3 --backup-path=/var/lib/mysql-cluster/BACKUP/BACKUP-1$> ndb_restore -b 1 -n 3 -r --num-slices=5 --slice-id=4 --backup-path=/var/lib/mysql-cluster/BACKUP/BACKUP-1$> ndb_restore -b 1 -n 4 -r --num-slices=5 --slice-id=0 --backup-path=/var/lib/mysql-cluster/BACKUP/BACKUP-1$> ndb_restore -b 1 -n 4 -r --num-slices=5 --slice-id=1 --backup-path=/var/lib/mysql-cluster/BACKUP/BACKUP-1$> ndb_restore -b 1 -n 4 -r --num-slices=5 --slice-id=2 --backup-path=/var/lib/mysql-cluster/BACKUP/BACKUP-1$> ndb_restore -b 1 -n 4 -r --num-slices=5 --slice-id=3 --backup-path=/var/lib/mysql-cluster/BACKUP/BACKUP-1$> ndb_restore -b 1 -n 4 -r --num-slices=5 --slice-id=4 --backup-path=/var/lib/mysql-cluster/BACKUP/BACKUP-1

      All of the commands just shown in this step can be executed in parallel, provided there are enough slots for connections to the cluster (see the description for the--backup-path option).

    3. Restore indexes as usual, as shown here:

      $> ndb_restore -b 1 -n 1 --rebuild-indexes --backup-path=/var/lib/mysql-cluster/BACKUP/BACKUP-1
    4. Finally, restore the epoch, using the command shown here:

      $> ndb_restore -b 1 -n 1 --restore-epoch --backup-path=/var/lib/mysql-cluster/BACKUP/BACKUP-1

    You should use slicing to restore the cluster data only; it is not necessary to employ--num-slices or--slice-id when restoring the metadata, indexes, or epoch information. If either or both of these options are used with thendb_restore options controlling restoration of these, the program ignores them.

    The effects of using the--parallelism option on the speed of restoration are independent of those produced by slicing or parallel restoration using multiple instances ofndb_restore (--parallelism specifies the number of parallel transactions executed by asinglendb_restore thread), but it can be used together with either or both of these. You should be aware that increasing--parallelism causesndb_restore to impose a greater load on the cluster; if the system can handle this, restoration should complete even more quickly.

    The value of--num-slices is not directly dependent on values relating to hardware such as number of CPUs or CPU cores, amount of RAM, and so forth, nor does it depend on the number of LDMs.

    It is possible to employ different values for this option on different data nodes as part of the same restoration; doing so should not in and of itself produce any ill effects.

  • --parallelism=#,-p

    Command-Line Format--parallelism=#
    TypeNumeric
    Default Value128
    Minimum Value1
    Maximum Value1024

    ndb_restore uses single-row transactions to apply many rows concurrently. This parameter determines the number of parallel transactions (concurrent rows) that an instance ofndb_restore tries to use. By default, this is 128; the minimum is 1, and the maximum is 1024.

    The work of performing the inserts is parallelized across the threads in the data nodes involved. This mechanism is employed for restoring bulk data from the.Data file—that is, the fuzzy snapshot of the data; it is not used for building or rebuilding indexes. The change log is applied serially; index drops and builds are DDL operations and handled separately. There is no thread-level parallelism on the client side of the restore.

  • --preserve-trailing-spaces,-P

    Command-Line Format--preserve-trailing-spaces

    Cause trailing spaces to be preserved when promoting a fixed-width character data type to its variable-width equivalent—that is, when promoting aCHAR column value toVARCHAR, or aBINARY column value toVARBINARY. Otherwise, any trailing spaces are dropped from such column values when they are inserted into the new columns.

    Note

    Although you can promoteCHAR columns toVARCHAR andBINARY columns toVARBINARY, you cannot promoteVARCHAR columns toCHAR orVARBINARY columns toBINARY.

  • --print

    Command-Line Format--print

    Causesndb_restore to print all data, metadata, and logs tostdout. Equivalent to using the--print-data,--print-meta, and--print-log options together.

    Note

    Use of--print or any of the--print_* options is in effect performing a dry run. Including one or more of these options causes any output to be redirected tostdout; in such cases,ndb_restore makes no attempt to restore data or metadata to an NDB Cluster.

  • --print-data

    Command-Line Format--print-data

    Causendb_restore to direct its output tostdout. Often used together with one or more of--tab,--fields-enclosed-by,--fields-optionally-enclosed-by,--fields-terminated-by,--hex, and--append.

    TEXT andBLOB column values are always truncated. Such values are truncated to the first 256 bytes in the output. This cannot currently be overridden when using--print-data.

  • --print-defaults

    Command-Line Format--print-defaults

    Print program argument list and exit.

  • --print-log

    Command-Line Format--print-log

    Causendb_restore to output its log tostdout.

  • --print-meta

    Command-Line Format--print-meta

    Print all metadata tostdout.

  • print-sql-log

    Command-Line Format--print-sql-log

    Log SQL statements tostdout. Use the option to enable; normally this behavior is disabled. The option checks before attempting to log whether all the tables being restored have explicitly defined primary keys; queries on a table having only the hidden primary key implemented byNDB cannot be converted to valid SQL.

    This option does not work with tables havingBLOB columns.

  • --progress-frequency=N

    Command-Line Format--progress-frequency=#
    TypeNumeric
    Default Value0
    Minimum Value0
    Maximum Value65535

    Print a status report eachN seconds while the backup is in progress. 0 (the default) causes no status reports to be printed. The maximum is 65535.

  • --promote-attributes,-A

    Command-Line Format--promote-attributes

    ndb_restore supports limitedattribute promotion in much the same way that it is supported by MySQL replication; that is, data backed up from a column of a given type can generally be restored to a column using alarger, similar type. For example, data from aCHAR(20) column can be restored to a column declared asVARCHAR(20),VARCHAR(30), orCHAR(30); data from aMEDIUMINT column can be restored to a column of typeINT orBIGINT. SeeSection 19.5.1.9.2, “Replication of Columns Having Different Data Types”, for a table of type conversions currently supported by attribute promotion.

    This option also makes it possible to restore aNOT NULL column asNULL.

    Attribute promotion byndb_restore must be enabled explicitly, as follows:

    1. Prepare the table to which the backup is to be restored.ndb_restore cannot be used to re-create the table with a different definition from the original; this means that you must either create the table manually, or alter the columns which you wish to promote usingALTER TABLE after restoring the table metadata but before restoring the data.

    2. Invokendb_restore with the--promote-attributes option (short form-A) when restoring the table data. Attribute promotion does not occur if this option is not used; instead, the restore operation fails with an error.

    When converting between character data types andTEXT orBLOB, only conversions between character types (CHAR andVARCHAR) and binary types (BINARY andVARBINARY) can be performed at the same time. For example, you cannot promote anINT column toBIGINT while promoting aVARCHAR column toTEXT in the same invocation ofndb_restore.

    Converting betweenTEXT columns using different character sets is not supported, and is expressly disallowed.

    When performing conversions of character or binary types toTEXT orBLOB withndb_restore, you may notice that it creates and uses one or more staging tables namedtable_name$STnode_id. These tables are not needed afterwards, and are normally deleted byndb_restore following a successful restoration.

  • --rebuild-indexes

    Command-Line Format--rebuild-indexes

    Enable multithreaded rebuilding of the ordered indexes while restoring a nativeNDB backup. The number of threads used for building ordered indexes byndb_restore with this option is controlled by theBuildIndexThreads data node configuration parameter and the number of LDMs.

    It is necessary to use this option only for the first run ofndb_restore; this causes all ordered indexes to be rebuilt without using--rebuild-indexes again when restoring subsequent nodes. You should use this option prior to inserting new rows into the database; otherwise, it is possible for a row to be inserted that later causes a unique constraint violation when trying to rebuild the indexes.

    Building of ordered indices is parallelized with the number of LDMs by default. Offline index builds performed during node and system restarts can be made faster using theBuildIndexThreads data node configuration parameter; this parameter has no effect on dropping and rebuilding of indexes byndb_restore, which is performed online.

    Rebuilding of unique indexes uses disk write bandwidth for redo logging and local checkpointing. An insufficient amount of this bandwidth can lead to redo buffer overload or log overload errors. In such cases you can runndb_restore--rebuild-indexes again; the process resumes at the point where the error occurred. You can also do this when you have encountered temporary errors. You can repeat execution ofndb_restore--rebuild-indexes indefinitely; you may be able to stop such errors by reducing the value of--parallelism. If the problem is insufficient space, you can increase the size of the redo log (FragmentLogFileSize node configuration parameter), or you can increase the speed at which LCPs are performed (MaxDiskWriteSpeed and related parameters), in order to free space more quickly.

  • --remap-column=db.tbl.col:fn:args

    Command-Line Format--remap-column=string
    TypeString
    Default Value[none]

    When used together with--restore-data, this option applies a function to the value of the indicated column. Values in the argument string are listed here:

    • db: Database name, following any renames performed by--rewrite-database.

    • tbl: Table name.

    • col: Name of the column to be updated. This column must be of typeINT orBIGINT. The column can also be but is not required to beUNSIGNED.

    • fn: Function name; currently, the only supported name isoffset.

    • args: Arguments supplied to the function. Currently, only a single argument, the size of the offset to be added by theoffset function, is supported. Negative values are supported. The size of the argument cannot exceed that of the signed variant of the column's type; for example, ifcol is anINT column, then the allowed range of the argument passed to theoffset function is-2147483648 to2147483647 (seeSection 13.1.2, “Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT”).

      If applying the offset value to the column would cause an overflow or underflow, the restore operation fails. This could happen, for example, if the column is aBIGINT, and the option attempts to apply an offset value of 8 on a row in which the column value is 4294967291, since4294967291 + 8 = 4294967299 > 4294967295.

    This option can be useful when you wish to merge data stored in multiple source instances of NDB Cluster (all using the same schema) into a single destination NDB Cluster, using NDB native backup (seeSection 25.6.8.2, “Using The NDB Cluster Management Client to Create a Backup”) andndb_restore to merge the data, where primary and unique key values are overlapping between source clusters, and it is necessary as part of the process to remap these values to ranges that do not overlap. It may also be necessary to preserve other relationships between tables. To fulfill such requirements, it is possible to use the option multiple times in the same invocation ofndb_restore to remap columns of different tables, as shown here:

    $> ndb_restore --restore-data --remap-column=hr.employee.id:offset:1000 \    --remap-column=hr.manager.id:offset:1000 --remap-column=hr.firstaiders.id:offset:1000

    (Other options not shown here may also be used.)

    --remap-column can also be used to update multiple columns of the same table. Combinations of multiple tables and columns are possible. Different offset values can also be used for different columns of the same table, like this:

    $> ndb_restore --restore-data --remap-column=hr.employee.salary:offset:10000 \    --remap-column=hr.employee.hours:offset:-10

    When source backups contain duplicate tables which should not be merged, you can handle this by using--exclude-tables,--exclude-databases, or by some other means in your application.

    Information about the structure and other characteristics of tables to be merged can obtained usingSHOW CREATE TABLE; thendb_desc tool; andMAX(),MIN(),LAST_INSERT_ID(), and other MySQL functions.

    Replication of changes from merged to unmerged tables, or from unmerged to merged tables, in separate instances of NDB Cluster is not supported.

  • --restore-data,-r

    Command-Line Format--restore-data

    OutputNDB table data and logs.

  • --restore-epoch,-e

    Command-Line Format--restore-epoch

    Add (or restore) epoch information to the cluster replication status table. This is useful for starting replication on an NDB Cluster replica. When this option is used, the row in themysql.ndb_apply_status having0 in theid column is updated if it already exists; such a row is inserted if it does not already exist. (SeeSection 25.7.9, “NDB Cluster Backups With NDB Cluster Replication”.)

  • --restore-meta,-m

    Command-Line Format--restore-meta

    This option causesndb_restore to printNDB table metadata.

    The first time you run thendb_restore restoration program, you also need to restore the metadata. In other words, you must re-create the database tables—this can be done by running it with the--restore-meta (-m) option. Restoring the metadata need be done only on a single data node; this is sufficient to restore it to the entire cluster.

    ndb_restore uses the default number of partitions for the target cluster, unless the number of local data manager threads is also changed from what it was for data nodes in the original cluster.

    When using this option, it is recommended that auto synchronization be disabled by settingndb_metadata_check=OFF untilndb_restore has completed restoring the metadata, after which it can it turned on again to synchronize objects newly created in the NDB dictionary.

    Note

    The cluster should have an empty database when starting to restore a backup. (In other words, you should start the data nodes with--initial prior to performing the restore.)

  • --restore-privilege-tables

    Command-Line Format--restore-privilege-tables
    DeprecatedYes

    No longer used.

  • --rewrite-database=olddb,newdb

    Command-Line Format--rewrite-database=string
    TypeString
    Default Valuenone

    This option makes it possible to restore to a database having a different name from that used in the backup. For example, if a backup is made of a database namedproducts, you can restore the data it contains to a database namedinventory, use this option as shown here (omitting any other options that might be required):

    $> ndb_restore --rewrite-database=product,inventory

    The option can be employed multiple times in a single invocation ofndb_restore. Thus it is possible to restore simultaneously from a database nameddb1 to a database nameddb2 and from a database nameddb3 to one nameddb4 using--rewrite-database=db1,db2 --rewrite-database=db3,db4. Otherndb_restore options may be used between multiple occurrences of--rewrite-database.

    In the event of conflicts between multiple--rewrite-database options, the last--rewrite-database option used, reading from left to right, is the one that takes effect. For example, if--rewrite-database=db1,db2 --rewrite-database=db1,db3 is used, only--rewrite-database=db1,db3 is honored, and--rewrite-database=db1,db2 is ignored. It is also possible to restore from multiple databases to a single database, so that--rewrite-database=db1,db3 --rewrite-database=db2,db3 restores all tables and data from databasesdb1 anddb2 into databasedb3.

    Important

    When restoring from multiple backup databases into a single target database using--rewrite-database, no check is made for collisions between table or other object names, and the order in which rows are restored is not guaranteed. This means that it is possible in such cases for rows to be overwritten and updates to be lost.

  • --skip-broken-objects

    Command-Line Format--skip-broken-objects

    This option causesndb_restore to ignore corrupt tables while reading a nativeNDB backup, and to continue restoring any remaining tables (that are not also corrupted). Currently, the--skip-broken-objects option works only in the case of missing blob parts tables.

  • --skip-table-check,-s

    Command-Line Format--skip-table-check

    It is possible to restore data without restoring table metadata. By default when doing this,ndb_restore fails with an error if a mismatch is found between the table data and the table schema; this option overrides that behavior.

    Some of the restrictions on mismatches in column definitions when restoring data usingndb_restore are relaxed; when one of these types of mismatches is encountered,ndb_restore does not stop with an error as it did previously, but rather accepts the data and inserts it into the target table while issuing a warning to the user that this is being done. This behavior occurs whether or not either of the options--skip-table-check or--promote-attributes is in use. These differences in column definitions are of the following types:

    • DifferentCOLUMN_FORMAT settings (FIXED,DYNAMIC,DEFAULT)

    • DifferentSTORAGE settings (MEMORY,DISK)

    • Different default values

    • Different distribution key settings

  • --skip-unknown-objects

    Command-Line Format--skip-unknown-objects

    This option causesndb_restore to ignore any schema objects it does not recognize while reading a nativeNDB backup. This can be used for restoring a backup made from a cluster running (for example) NDB 7.6 to a cluster running NDB Cluster 7.5.

  • --slice-id=#

    Command-Line Format--slice-id=#
    TypeInteger
    Default Value0
    Minimum Value0
    Maximum Value1023

    When restoring by slices, this is the ID of the slice to restore. This option is always used together with--num-slices, and its value must be always less than that of--num-slices.

    For more information, see the description of the--num-slices elsewhere in this section.

  • --tab=dir_name,-Tdir_name

    Command-Line Format--tab=path
    TypeDirectory name

    Causes--print-data to create dump files, one per table, each namedtbl_name.txt. It requires as its argument the path to the directory where the files should be saved; use. for the current directory.

  • --timestamp-printouts

    Command-Line Format--timestamp-printouts{=true|false}
    TypeBoolean
    Default Valuetrue

    Causes info, error, and debug log messages to be prefixed with timestamps.

    This option is enabled by default. Disable it with--timestamp-printouts=false.

  • --usage

    Command-Line Format--usage

    Display help text and exit; same as--help.

  • --verbose=#

    Command-Line Format--verbose=#
    TypeNumeric
    Default Value1
    Minimum Value0
    Maximum Value255

    Sets the level for the verbosity of the output. The minimum is 0; the maximum is 255. The default value is 1.

  • --version

    Command-Line Format--version

    Display version information and exit.

  • --with-apply-status

    Command-Line Format--with-apply-status

    Restore all rows from the backup'sndb_apply_status table (except for the row havingserver_id = 0, which is generated using--restore-epoch). This option requires that--restore-data also be used.

    If thendb_apply_status table from the backup already contains a row withserver_id = 0,ndb_restore--with-apply-status deletes it. For this reason, we recommend that you usendb_restore--restore-epoch after invokingndb_restore with the--with-apply-status option. You can also use--restore-epoch concurrently with the last of any invocations ofndb_restore--with-apply-status used to restore the cluster.

    For more information, seendb_apply_status Table.

Typical options for this utility are shown here:

ndb_restore [-cconnection_string] -nnode_id -bbackup_id \      [-m] -r --backup-path=/path/to/backup/files

Normally, when restoring from an NDB Cluster backup,ndb_restore requires at a minimum the--nodeid (short form:-n),--backupid (short form:-b), and--backup-path options.

The-c option is used to specify a connection string which tellsndb_restore where to locate the cluster management server (seeSection 25.4.3.3, “NDB Cluster Connection Strings”). If this option is not used, thenndb_restore attempts to connect to a management server onlocalhost:1186. This utility acts as a cluster API node, and so requires a free connectionslot to connect to the cluster management server. This means that there must be at least one[api] or[mysqld] section that can be used by it in the clusterconfig.ini file. It is a good idea to keep at least one empty[api] or[mysqld] section inconfig.ini that is not being used for a MySQL server or other application for this reason (seeSection 25.4.3.7, “Defining SQL and Other API Nodes in an NDB Cluster”).

ndb_restore can decrypt an encrypted backup using--decrypt and--backup-password. Both options must be specified to perform decryption. See the documentation for theSTART BACKUP management client command for information on creating encrypted backups.

You can verify thatndb_restore is connected to the cluster by using theSHOW command in thendb_mgm management client. You can also accomplish this from a system shell, as shown here:

$> ndb_mgm -e "SHOW"

Error reporting. ndb_restore reports both temporary and permanent errors. In the case of temporary errors, it may able to recover from them, and reportsRestore successful, but encountered temporary error, please look at configuration in such cases.

Important

After usingndb_restore to initialize an NDB Cluster for use in circular replication, binary logs on the SQL node acting as the replica are not automatically created, and you must cause them to be created manually. To cause the binary logs to be created, issue aSHOW TABLES statement on that SQL node before runningSTART REPLICA. This is a known issue in NDB Cluster.