Backup & Restore

OrientDB supports back and and restore operations, like any database management system.

The BACKUP DATABASE command executes a complete backup on the currently open database. It compresses the backup the backup using the ZIP algorithm. To restore the database from the subsequent .zip file, you can use the RESTORE DATABASE command.

Backups and restores are much faster than the EXPORT DATABASE and IMPORT DATABASE commands. You can also automate backups using the Automatic Backup server plugin. Additionally, beginning with version 2.2 of Enterprise Edition OrientDB introduces major support for incremental backups.

Backups versus Exports

During backups, the BACKUP DATABASE command produces a consistent copy of the database. During this process, the database locks all write operations, waiting for the backup to finish. If you need perform reads and writes on the database during backups, set up a distributed cluster of nodes.

By contrast, the EXPORT DATABASE command doesn't lock the database, allowing concurrent writes to occur during the export process. Consequentially, the export may include changes made after you initiated the export, which may result in inconsistencies.

Using the Backup Script

Beginning in version 1.7.8, OrientDB introduces a backup.sh script found in the $ORIENTDB_HOME/bin directory. This script allows you to initiate backups from the system console.

Syntax

./backup.sh <db-url> <user> <password> <destination> [<type>]
  • <db-url> Defines the URL for the database to back up.
  • <user> Defines the user to run the backup.
  • <password> Defines the password for the user.
  • <destination> Defines the path to the backup file the script creates, (use the .zip extension).
  • <type> Defines the backup type. Supported types:
    • default Locks the database during the backup.
    • lvm Executes an LVM copy-on-write snapshot in the background.

Examples

  • Backup a database opened using plocal:

    $ $ORIENTDB_HOME/bin/backup.sh plocal:../database/testdb \
          admin adminpasswd \
          /path/to/backup.zip
    
  • Perform a non-blocking LVM backup, using plocal:

    $ $ORIENTDB_HOME/bin/backup.sh plocal:../database/testdb \
          admin adminpasswd \
          /path/to/backup.zip \
          lvm
    
  • Perform a non-blocking LVM backup, using a remote database hosted at localhost:

    $ $ORIENTDB_HOME/bin/backup.sh remote:localhost/testdb \
          root rootpasswd \
          /path/to/backup.zip \
          lvm
    
  • Perform a backup using the OrientDB Console with the BACKUP command:

    orientdb> CONNECT PLOCAL:../database/testdb/ admin adminpasswd
    orientdb> BACKUP DATABASE /path/to/backup.zip
    
    Backup executed in 0.52 seconds.
    

NOTE Non-blocking backups require that the operating system support LVM. For more information, see

Restoring Databases

Once you have created your backup.zip file, you can restore it to the database either through the OrientDB Console, using the RESTORE DATABASE command.

orientdb> RESTORE DATABASE /backups/mydb.zip

Restore executed in 6.33 seconds

Bear in mind that OrientDB does not support merging during restores. If you need to merge the old data with new writes, instead use EXPORT DATABASE and IMPORT DATABASE commands, instead.

For more information, see

results matching ""

    No results matching ""