How To Import and Export an OrientDB Database on Ubuntu 14.04

Published on January 6, 2016
How To Import and Export an OrientDB Database on Ubuntu 14.04


OrientDB is a multi-model, NoSQL database, with support for graph and document databases. It is a Java application and can run on any operating system. It’s also fully ACID-complaint with support for multi-master replication. It is developed by a company of the same name, with an Enterprise and a Community edition.

In this article, we’ll be using the GratefulDeadConcerts database to demonstrate how to export and import an OrientDB database. That database comes with every installation of OrientDB, so you don’t have to create a new one.


To complete the tutorial, you’ll need the following:

If you all all those things in place, let’s get started.

Step 1 — Export an Existing OrientDB Database

To import an OrientDB database, you must first export the DB to be imported. In this step, we’ll export the database that we need to import.

If OrientDB is not running, start it:

  1. sudo service orientdb start

If you aren’t sure whether or not it is running, you can always check its status:

  1. sudo service orientdb status

Then connect to the server using the OrientDB console:

  1. sudo -u orientdb /opt/orientdb/bin/console.sh

The output should be:

OrientDB console v.2.1.3 (build UNKNOWN@r; 2015-10-04 10:56:30+0000) www.orientdb.com Type 'help' to display all the supported commands. Installing extensions for GREMLIN language v.2.6.0 orientdb>

Connect to the database that you wish to export. Here we’re connecting to the GratefulDeadConcerts database using the database’s default user admin and its password admin:

  1. connect plocal:/opt/orientdb/databases/GratefulDeadConcerts admin admin

You should see an output like this:

Connecting to database [plocal:/opt/orientdb/databases/GratefulDeadConcerts] with user 'admin'...OK orientdb {db=GratefulDeadConcerts}>

Alternatively, you can also connect to the database using the remote mode, which allows multiple users to access the same database.

  1. connect remote: admin admin

The connection output should be of this sort:

Disconnecting from the database [null]...OK Connecting to database [remote:] with user 'admin'...OK orientdb {db=GratefulDeadConcerts}>

Now, export the database. The export command exports the current database to a gzipped, compressed JSON file. In this example, we’re exporting it into OrientDB’s database directory /opt/orientdb/databases:

  1. export database /opt/orientdb/databases/GratefulDeadConcerts.export

The complete export command output for the target database is:

Exporting current database to: database /opt/orientdb/databases/GratefulDeadConcerts.export in GZipped JSON format ... Started export of database 'GratefulDeadConcerts' to /opt/orientdb/databases/GratefulDeadConcerts.export.gz... Exporting database info...OK Exporting clusters...OK (15 clusters) Exporting schema...OK (14 classes) Exporting records... - Cluster 'internal' (id=0)...OK (records=3/3) - Cluster 'index' (id=1)...OK (records=5/5) - Cluster 'manindex' (id=2)...OK (records=1/1) - Cluster 'default' (id=3)...OK (records=0/0) - Cluster 'orole' (id=4)...OK (records=3/3) - Cluster 'ouser' (id=5)...OK (records=3/3) - Cluster 'ofunction' (id=6)...OK (records=0/0) - Cluster 'oschedule' (id=7)...OK (records=0/0) - Cluster 'orids' (id=8)...OK (records=0/0) - Cluster 'v' (id=9).............OK (records=809/809) - Cluster 'e' (id=10)...OK (records=0/0) - Cluster 'followed_by' (id=11).............OK (records=7047/7047) - Cluster 'written_by' (id=12).............OK (records=501/501) - Cluster 'sung_by' (id=13).............OK (records=501/501) - Cluster '_studio' (id=14)...OK (records=0/0) Done. Exported 8873 of total 8873 records Exporting index info... - Index OUser.name...OK - Index dictionary...OK - Index ORole.name...OK OK (3 indexes) Exporting manual indexes content... - Exporting index dictionary ...OK (entries=0) OK (1 manual indexes) Database export completed in 60498ms

That completes the export step.

Open another terminal to your Droplet, and list the contents of the database directory:

  1. ls -lh /opt/orientdb/databases

You should see the original database plus the compressed file for your database export:

total 164K drwxr-xr-x 2 orientdb orientdb 4.0K Nov 27 02:36 GratefulDeadConcerts -rw-r--r-- 1 orientdb orientdb 158K Nov 27 14:19 GratefulDeadConcerts.export.gz

Back at the terminal with your OrientDB console, you may now disconnect from the current database by typing:

  1. disconnect

If successfully disconnected, you should get an output similar to:

Disconnecting from the database [GratefulDeadConcerts]...OK orientdb>

Keep the connection to the console open, because you’ll be using it in the next step.

Step 2 — Import Database

In this step, we’ll import the database we exported in Step 1. By default, importing a database overwrites the existing data in the one it’s being imported into. So, first connect to the target database. In this example, we’ll be connecting to the default database that we used in Step 1.

  1. connect plocal:/opt/orientdb/databases/GratefulDeadConcerts admin admin

You can also connect using:

  1. connect remote: admin admin

Either output should be similar to this:

Connecting to database [remote:] with user 'admin'...OK orientdb {db=GratefulDeadConcerts}>

With the connection established, let’s import the exported file:

  1. import database /opt/orientdb/databases/GratefulDeadConcerts.export.gz

Depending on the number of records to be imported, this can take more than a few minutes. So sit back and relax, or reach for that cup of your favorite liquid.

The import output should be (output truncated):

Importing database database /opt/orientdb/databases/GratefulDeadConcerts.export.gz... Started import of database 'remote:' from /opt/orientdb/databases/GratefulDeadConcerts.export.gz... Non merge mode (-merge=false): removing all default non security classes ... Done. Imported 8,865 records in 915.51 secs Importing indexes ... - Index 'OUser.name'...OK - Index 'dictionary'...OK - Index 'ORole.name'...OK Done. Created 3 indexes. Importing manual index entries... - Index 'dictionary'...OK (0 entries) Done. Imported 1 indexes. Rebuild of stale indexes... Stale indexes were rebuilt... Deleting RID Mapping table...OK Database import completed in 1325943 ms

You can now disconnect from the database:

  1. disconnect

The exit the OrientDB console and return to your regular shell prompt, type exit:

  1. exit


You’ve just seen how to export and import an OrientDB database. Note that the import/export feature does not lock the database during the entire process, so it’s possible for it to be receiving writes as the process is taking place. For more information on this topic, see the official OrientDB export/import guide.

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the authors
Default avatar


Default avatar
Tammy Fox


Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
Leave a comment

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel