Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Copy / Clone Database


If you only want to move/copy database on the same server, then you can use cubrid copydb.

If you desire to copy a database from one server to another, then all you need to do is follow a few simple steps. For the purpose of this example, let's say we have a database named "demodb" and we want to create another copy of it named "copydb".

Step 1. Export the database

cubrid unloaddb demodb

This command will create 3 files: demodb_objects, demodb_indexes and demodb_schema. The first one contains all the data, the second one the indexes created on all tables and the last one contains all the table definitions.

Step 2. Create the new database

cubrid createdb testdb

Important! createdb creates the database files in the current directory. Make sure that run this command from the directory where you want your new database to be created in.

Step 3. Load the exported data

cubrid loaddb testdb -d demodb_objects -i demodb_indexes -s demodb_schema -u dba

Important!  Make sure that the testdb database is not running before running this command. If you are running this command on a Linux system, make sure that all files (demodb_objects, demodb_indexes, demodb_schema) are owned by cubrid user. Use chown cubrid:cubrid on the files to correctly set the user and group.

Step 4 (optional). Start the new database

cubrid server start testdb

After everything is set up, this command starts the new database and you can now connect to it using csql, cubrid manager or by using one of the available drivers.

Important! This approach to copy a database is the fastest, but it does not guarantee that the order of the data is preserved. For more information regarding this problem, check out this forum thread.

comments powered by Disqus
Page info
viewed 2485 times
translations en
Author
posted 2 years ago by
CUBRID
Contributors
updated 2 years ago by
View revisions
Share this article