Exports the current opened database to a file. The exported file is in JSON format using the Export-Format. By default the file is compressed using the GZIP algorithm. The Export/Import commands allow to migrate the database between different releases of OrientDB without loosing data. If you receive an error about the database version, export the database using the same version of OrientDB that has generated the database.
Export doesn't lock your database, but browses it. This means that concurrent operation can be executed during the export, but the exported database couldn't be the exact replica when you issued the command because concurrent updates could occurs. If you need a snapshot of database at a point in a time, please use Backup.
Once exported, use the Import to restore it. The database will be imported and will be ready to be used. Look also to Backup Database and Restore Database commands.
By default the export command exports the full database, but there are some flags to disable some parts.
export database <output-file>
[-excludeAll]
[-includeClass=<class-name>*]
[-excludeClass=<class-name>*]
[-includeCluster=<cluster-name>*]
[-excludeCluster=<cluster-name>*]
[-includeInfo=<true|false>]
[-includeClusterDefinitions=<true|false>]
[-includeSchema=<true|false>]
[-includeSecurity=<true|false>]
[-includeRecords=<true|false>]
[-includeIndexDefinitions=<true|false>]
[-includeManualIndexes=<true|false>]
[-compressionLevel=<0-9>]
[-compressionBuffer=<bufferSize>]
Where:
orientdb> export database C:\temp\petshop.export
Exporting current database to: C:\temp\petshop.export...
Exporting database info...OK
Exporting dictionary...OK
Exporting schema...OK
Exporting clusters...
- Exporting cluster 'metadata' (records=11) -> ...........OK
- Exporting cluster 'index' (records=0) -> OK
- Exporting cluster 'default' (records=779) -> OK
- Exporting cluster 'csv' (records=1000) -> OK
- Exporting cluster 'binary' (records=1001) -> OK
- Exporting cluster 'person' (records=7) -> OK
- Exporting cluster 'animal' (records=5) -> OK
- Exporting cluster 'animalrace' (records=0) -> OK
- Exporting cluster 'animaltype' (records=1) -> OK
- Exporting cluster 'orderitem' (records=0) -> OK
- Exporting cluster 'order' (records=0) -> OK
- Exporting cluster 'city' (records=3) -> OK
Export of database completed.
orientdb> export database functions.gz -includeClass=OFunction
-includeInfo=false
-includeClusterDefinitions=false
-includeSchema=false
-includeIndexDefinitions=false
-includeManualIndexes=false
Export command can be used in Java and any language on top of the JVM by using the class ODatabaseExport. Example:
ODatabaseDocumentTx db = new ODatabaseDocumentTx("plocal:/temp/mydb");
db.open("admin", "admin");
try{
OCommandOutputListener listener = new OCommandOutputListener() {
@Override
public void onMessage(String iText) {
System.out.print(iText);
}
};
ODatabaseExport export = new ODatabaseExport(db, "/temp/export", listener);
export.exportDatabase();
export.close();
} finally {
db.close();
}