Using NuoDB Migrator to Copy NuoDB Databases

In addition to migrating databases from other RDBMSs to NuoDB, NuoDB Migrator allows you to dump and load data from one NuoDB Database to another.

NuoDB Migrator as Dump/Load or Backup/Restore of a NuoDB database

NuoDB Migrator can also be used to copy a source NuoDB database to a target NuoDB database. The only difference is that the source JDBC driver and URL are provided for a NuoDB database connection and not a 3rd party database connection. To dump the source NuoDB database use the following NuoDB Migrator dump command:

nuodb-migrator dump                                         \
        --source.driver=com.nuodb.jdbc.Driver               \
        --source.url=jdbc:com.nuodb://host/database_name    \
        --source.schema=my_schema                           \
        --source.username=userid                            \
        --source.password=passwd                            \
        --output.type=csv                                   \
        --output.path=path_for_dump_files

To load the target NuoDB database use the following NuoDB Migrator load command:

nuodb-migrator load                                        \
        --target.url=jdbc:com.nuodb://host/database_name   \
        --target.username=userid                           \
        --target.password=passwd                           \
        --input.path=path_for_dump_files

NuoDB JDBC Driver Information

Class Name

com.nuodb.jdbc.Driver

JDBC URL

jdbc:com.nuodb://host:port/dbname

Configuring Class Path

To access data stored in NuoDB, NuoDB Migrator uses the NuoDB JDBC driver.

Check whether the drivers you require are loaded. If not down load them from GitHub and the other public sites stated in our documentation. For more information, see NuoDB Community Drivers on GitHub and NuoDB Drivers Available at Other Public Sites.

For advanced cases you can override the NUODB_HOME environment variable with a valid NuoDB installation directory from a command line shell.

Alternatively, NuoDB Migrator can pick up a JDBC Driver from the system CLASSPATH environment variable.

Dump/Load Examples

To configurate a connection to a NuoDB database you should provide the JDBC driver class name, the JDBC connection URL, schema name, username and password for authentication.

schema

The schema command captures the HOCKEY schema and saves it to a file specified by the --output.path parameter. Suppose we had a NuoDB database installed on the machine myserver loaded with the HOCKEY schema and data from the QuickStart database and we want to dump that data and load it into a local NuoDB database we have just created.

$ nuodb-migrator schema \
        --source.driver=com.nuodb.jdbc.Driver           \
        --source.url=jdbc:com.nuodb://myserver/test     \
        --source.schema=hockey                          \
        --source.username=dba                           \
        --source.password=goalie                        \
        --output.path=/tmp/schema.sql

Run schema.sql in nuosql to load the schema into the NuoDB testdb database and into the schema NEWHOCKEY.

$ nuosql testdb@localhost --user cloud --password psswd --schema newhockey --file /tmp/schema.sql

dump

The following command creates a dump of all tables from the myserver NuoDB database named test, found in schema HOCKEY in CSV format. Dumped data files will be saved in /tmp/dump directory.

$ nuodb-migrator dump \
        --source.driver=com.nuodb.jdbc.Driver           \
        --source.url=jdbc:com.nuodb://myserver/test     \
        --source.schema=hockey                          \
        --source.username=dba                           \
        --source.password=goalie                        \
        --output.type=csv                               \
        --output.path=/temp/dump

load

Loading a previously generated dump from --input.path to a NuoDB database testdb into --target.schema is performed using load command.

$ nuodb-migrator load     \
        --target.url=jdbc:com.nuodb://localhost/testdb  \
        --target.schema=newhockey                       \
        --target.username=cloud                         \
        --target.password=passwd                        \
        --input.path=/tmp/dump