Console - EXPORT

Exports the current database to a file. OrientDB uses a JSON-based Export Format. By default, it compresses the file using the GZIP algorithm.

With the IMPORT command, this allows you to migrate the database between different versions of OrientDB without losing data.

If you receive an error about the database version, export the database using the same version of OrientDB that has generated the database.

Bear in mind, exporting a database browses it, rather than locking it. While this does mean that concurrent operations can execute during the export, it also means that you cannot create an exact replica of the database at the point when the command is issued. In the event that you need to create a snapshot, use the BACKUP command.

You can restore a database from an export using the IMPORT.

NOTE: While the export format is JSON, there are some constraints in the field order. Editing this file or adjusting its indentation may cause imports to fail.

Syntax

By default, this command exports the full database. Use its options to disable the parts you don’t need to export.

  1. EXPORT DATABASE <output-file>
  2. [-excludeAll]
  3. [-includeClass=<class-name>*]
  4. [-excludeClass=<class-name>*]
  5. [-includeCluster=<cluster-name>*]
  6. [-excludeCluster=<cluster-name>*]
  7. [-includeInfo=<true|false>]
  8. [-includeClusterDefinitions=<true|false>]
  9. [-includeSchema=<true|false>]
  10. [-includeSecurity=<true|false>]
  11. [-includeRecords=<true|false>]
  12. [-includeIndexDefinitions=<true|false>]
  13. [-includeManualIndexes=<true|false>]
  14. [-compressionLevel=<0-9>]
  15. [-compressionBuffer=<bufferSize>]
  • <output-file> Defines the path to the output file.
  • -excludeAll Sets the export to exclude everything not otherwise included through command options
  • -includeClass Export includes certain classes, specifically those defined by a space-separated list.
  • -excludeClass Export excludes certain classes, specifically those defined by a space-separated list.
  • -includeCluster Export includes certain clusters, specifically those defined by a space-separated list.
  • -excludeCluster Export excludes certain clusters, specifically those defined by a space-separated list.
  • -includeInfo Defines whether the export includes database information.
  • -includeClusterDefinitions Defines whether the export includes cluster definitions.
  • -includeSchmea Defines whether the export includes the database schema.
  • -includeSecurity Defines whether the export includes database security parameters.
  • -includeRecords Defines whether the export includes record contents.
  • -includeIndexDefinitions Defines whether the export includes the database index definitions.
  • -includeManualIndexes Defines whether the export includes manual index contents.
  • -compressionLevel Defines the compression level to use on the export, in a range between 0 (no compression) and 9 (maximum compression). The default is 1. (Feature introduced in version 1.7.6.)
  • -compressionBuffer Defines the compression buffer size in bytes to use in compression. The default is 16kb. (Feature introduced in version 1.7.6.)

Examples

  • Export the current database, including everything:

    1. orientdb> EXPORT DATABASE C:\temp\petshop.export
    2.  
    3. Exporting current database to: C:\temp\petshop.export...
    4.  
    5. Exporting database info...OK
    6. Exporting dictionary...OK
    7. Exporting schema...OK
    8. Exporting clusters...
    9. - Exporting cluster 'metadata' (records=11) -> ...........OK
    10. - Exporting cluster 'index' (records=0) -> OK
    11. - Exporting cluster 'default' (records=779) -> OK
    12. - Exporting cluster 'csv' (records=1000) -> OK
    13. - Exporting cluster 'binary' (records=1001) -> OK
    14. - Exporting cluster 'person' (records=7) -> OK
    15. - Exporting cluster 'animal' (records=5) -> OK
    16. - Exporting cluster 'animalrace' (records=0) -> OK
    17. - Exporting cluster 'animaltype' (records=1) -> OK
    18. - Exporting cluster 'orderitem' (records=0) -> OK
    19. - Exporting cluster 'order' (records=0) -> OK
    20. - Exporting cluster 'city' (records=3) -> OK
    21. Export of database completed.
  • Export the current database, including only its functions:

    1. orientdb> EXPORT DATABASE functions.gz -includeClass=OFunction -includeInfo=FALSE
    2. -includeClusterDefinitions=FALSE -includeSchema=FALSE
    3. -includeIndexDefinitions=FALSE -includeManualIndexes=FALSE
  • Alternatively, you can simplify the above by excluding all, then including only those features that you need. For instance, export the current database, including only the schema:

    1. orientdb> EXPORT DATABASE schema.gz -excludeALL -includeSchmea=TRUE

Export API

In addition to the Console, you can also trigger exports through Java and any other language that runs on the JVM, by using the ODatabaseExport class.

For example:

  1. ODatabaseDocumentTx db = new ODatabaseDocumentTx("plocal:/temp/mydb");
  2. db.open("admin", "admin");
  3. try{
  4. OCommandOutputListener listener = new OCommandOutputListener() {
  5. @Override
  6. public void onMessage(String iText) {
  7. System.out.print(iText);
  8. }
  9. };
  10. ODatabaseExport export = new ODatabaseExport(db, "/temp/export", listener);
  11. export.exportDatabase();
  12. export.close();
  13. } finally {
  14. db.close();
  15. }

For more information on backups and restores, imports and exports, see the following commands:

as well as the following pages:

For more information on other commands, see Console Commands.