User Guide > User Guide > A. Command Reference > clonedb Command--Clone a Database
Was this helpful?
clonedb Command--Clone a Database
Valid on Linux.
The clonedb utility clones a database between two servers. It can be used to move a database from one machine or cluster to another. It can be used, for example, to clone a production database for testing purposes.
The two instances must be at the same product version, including the same service pack level. Source and target II_SYSTEMs can differ.
Clonedb copies all of the schema in a database to the target; no partial database cloning is possible. The schema the database contains need not have active users in the target installation.
Cloning means making identical copies, so a database cannot be cloned between operating systems or product variants, such as Vector and VectorH.
To clone an encrypted datatbase, you must provide the correct passphrase for the database. Clonedb then verifies the given passphrase by recycling the installation and running ENABLE PASSPHRASE against the database. After clonedb successfully completes, the newly cloned database is left unlocked.
Notes:
You cannot clone a database from one instance to another on the same machine.
The alterdb -readonly command is run on the source database as part of the clonedb command so no changes are made to the source database during the clonedb operation. If the source database has open sessions, the alterdb within clonedb will stall until sessions are ended.
We recommend taking a checkpoint of the cloned database after cloning is complete.
This command has the following format:
clonedb -source_dbname source_dbname -source source_machine
        ‑source_ii_system source_II_SYSTEM
        ‑target_dbname target_dbname
        -target target_machine ‑target_ii_system target_II_SYSTEM
        [-key keyfile] [-trial] [‑source_user source_user] [-target_user target_user
-source_dbname source_dbname
Specifies the name of the database to be copied.
-source source_machine
Specifies the name of the source machine.
-source_ii_system source_II_SYSTEM
Specifies the II_SYSTEM path on the source machine.
-target_dbname target_dbname
Specifies the name of the target database.
-target target_machine
Specifies the name of the target machine.
-target_ii_system target_II_SYSTEM
Specifies the II_SYSTEM path on the target machine.
-key keyfile
Specifies the fully-qualified RSA key file for SSH authentication (for example: /.ssh/id_rsa). Specifying an authentication key is recommended; otherwise password authentication will be required multiple times instead of once. An authentication key can be generated by using the Linux utility ssh-keygen.
-trial
Performs a trial copy (no files copied). The target installation is started, a database created. When used with an encrypted database, the destination database will not be encrypted.
‑source_user source_user
Specifies the name of the database user (installation owner) on the source system. Use this option to override the current user.
-target_user username
Specifies the name of the database user (installation owner) on the target system. Use this option to override the current user.
‑v
Runs clonedb in verbose mode, which displays messages as the operation proceeds.
Last modified date: 12/06/2024