Console - RESTORE DATABASE
Restores a database from a backup. It must be done against a new database. It does not support restores that merge with an existing database. If you need to backup and restore to an existing database, use the EXPORT DATABASE and IMPORT DATABASE commands.
OrientDB Enterprise Edition version 2.2 and major, support incremental backup.
To create a backup file to restore from, use the BACKUP DATABASE command.
Syntax
RESTORE DATABASE <backup-file>|<incremental-backup-directory>
<backup-file>Defines the database file you want to restore.<incremental-backup-directory>Defines the database directory you want to restore from an incremental backup. Available only in OrientDB Enterprise Edition version 2.2 and major.
Example of full restore
Create a new database to receive the restore:
orientdb>CREATE DATABASE PLOCAL:/tmp/mydbRestore the database from the
mydb.zipbackup file:orientdb {db=/tmp/mydb}>RESTORE DATABASE /backups/mydb.zip
Example of incremental restore
This is available only in OrientDB Enterprise Edition version 2.2 and major.
Open a database to receive the restore:
orientdb>
CONNECT PLOCAL:/tmp/mydbRestore the database from the
/backupbackup directory:orientdb {db=/tmp/mydb}>RESTORE DATABASE /backup
For more information, see the
BACKUP DATABASE,EXPORT DATABASE,IMPORT DATABASEcommands. For more information on other commands, see Console Commands.
Restore API
In addition to the console commands, you can also execute restores through the Java API or with any language that can run on top of the JVM using the restore() method against the database instance.
db.restore(in, options, callable, listener);
inDefines theInputStreamused to read the backup content. Uses aFileInputStreamto read the backup content from disk.optionsDefines backup options, such asMap<String, Object>object.callableDefines the callback to execute when the database is locked.listenerListener called for backup messages.compressionLevelDefines the Zip Compression level, between0for no compression and9for maximum compression. The greater the compression level, the smaller the final backup content and the greater the CPU and time it takes to execute.bufferSizeBuffer size in bytes, the greater the buffer the more efficient the compression.
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);
}
};
InputStream out = new FileInputStream("/temp/mydb.zip");
db.restore(in,null,null,listener);
} finally {
db.close();
}