Automatic Backup Server Plugin

Using this server plugin, OrientDB executes regular backups on the databases. It implements the Java class:

  1. com.orientechnologies.orient.server.handler.OAutomaticBackup

Plugin Configuration

Beginning with version 2.2, OrientDB manages the server plugin configuration from a separate JSON. You can update this file manually or through OrientDB Studio.

To enable automatic backups, use the following <handler> section in the config/orientdb-server-config.xml configuration file:

  1. <!-- AUTOMATIC BACKUP, TO TURN ON SET THE 'ENABLED' PARAMETER TO 'true' -->
  2. <handler class="com.orientechnologies.orient.server.handler.OAutomaticBackup">
  3. <parameters>
  4. <parameter name="enabled" value="false"/>
  5. <!-- LOCATION OF JSON CONFIGURATION FILE -->
  6. <parameter name="config" value="${ORIENTDB_HOME}/config/automatic-backup.json"/>
  7. </parameters>
  8. </handler>

This section tells the OrientDB server to read the file at $ORIENTDB_HOME/config/automatic-backup.json for the automatic backup configuration.

  1. {
  2. "enabled": true,
  3. "mode": "FULL_BACKUP",
  4. "exportOptions": "",
  5. "delay": "4h",
  6. "firstTime": "23:00:00",
  7. "targetDirectory": "backup",
  8. "targetFileName": "${DBNAME}-${DATE:yyyyMMddHHmmss}.zip",
  9. "compressionLevel": 9,
  10. "bufferSize": 1048576
  11. }
  • "enabled" Defines whether it uses automatic backups. The supported values are:
    • true Enables automatic backups.
    • false Disables automatic backups. This is the default setting.
  • "mode" Defines the backup mode. The supported values are:
    • "FULL_BACKUP" Executes a full backup. Prior to version 2.2, this was the only mode available. This operation blocks the database.
    • "INCREMENTAL_BACKUP" Executes an incremental backup. Uses one directory per database. This operation doesn’t block the database.
    • "EXPORT" Executes an database export, using gziped JSON format. This operation is not blocking.
  • "exportOptions" Defines export options to use with that mode. This feature was introduced in version 2.2.
  • "delay" Defines the delay time for each backup. Supports the following suffixes:
    • ms Delay measured in milliseconds.
    • s Delay measured in seconds.
    • m Delay measured in minutes.
    • h Delay measured in hours.
    • d Delay measured in days.
  • "firstTime" Defines when to initiate the first backup in the schedule. It uses the format of HH:mm:ss in the GMT time zone, on the current day.
  • "targetDirectory" Defines the target directory to write backups. By default, it is set to the backup/ directory.
  • "targetFileName" Defines the target filename. This parameter supports the use of the following variables, (that is, "${DBNAME}-backup.zip" produces mydatabase-backup.zip):
    • ${DBNAME} Renders the database name.
    • ${DATE} Renders the current date, using the Java DateTime syntax format.
  • "dbInclude" Defines in a list the databases to include in the automatic backups. If empty, it backs up all databases.
  • "dbExclude" Defines in a list the databases to exclude from the automatic backups.
  • "bufferSize" Defines the in-memory buffer sizes to use in compression. By default, it is set to 1MB. Larger buffers mean faster backups, but they in turn consume more RAM.
  • "compressionLevel" Defines the compression level for the resulting ZIP file. By default it is set to the maximum level of 9. Set it to a lower value if you find that the backup takes too much time.

Legacy Plugin Configuration

In versions prior to 2.2, the only option in configuring automatic backups is to use the config/orientdb-server-config.xml configuration file. Beginning with version 2.2 you can manage automatic backup configuration through a separate JSON file or use the legacy approach.

The example below configures automatic backups/exports on the database as a Server Plugin.

  1. <!-- AUTOMATIC BACKUP, TO TURN ON SET THE 'ENABLED' PARAMETER TO 'true' -->
  2. <handler class="com.orientechnologies.orient.server.handler.OAutomaticBackup">
  3. <parameters>
  4. <parameter name="enabled" value="false" />
  5. <!-- CAN BE: FULL_BACKUP, INCREMENTAL_BACKUP, EXPORT -->
  6. <parameter name="mode" value="FULL_BACKUP"/>
  7. <!-- OPTION FOR EXPORT -->
  8. <parameter name="exportOptions" value=""/>
  9. <parameter name="delay" value="4h" />
  10. <parameter name="target.directory" value="backup" />
  11. <!-- ${DBNAME} AND ${DATE:} VARIABLES ARE SUPPORTED -->
  12. <parameter name="target.fileName" value="${DBNAME}-${DATE:yyyyMMddHHmmss}.zip" />
  13. <!-- DEFAULT: NO ONE, THAT MEANS ALL DATABASES.
  14. USE COMMA TO SEPARATE MULTIPLE DATABASE NAMES -->
  15. <parameter name="db.include" value="" />
  16. <!-- DEFAULT: NO ONE, THAT MEANS ALL DATABASES.
  17. USE COMMA TO SEPARATE MULTIPLE DATABASE NAMES -->
  18. <parameter name="db.exclude" value="" />
  19. <parameter name="compressionLevel" value="9"/>
  20. <parameter name="bufferSize" value="1048576"/>
  21. </parameters>
  22. </handler>
  • enabled Defines whether it uses automatic backups. Supported values are:
    • true Enables automatic backups.
    • false Disables automatic backups. This is the default setting.
  • mode/> Defines the backup mode. Supported values are:
    • FULL_BACKUP Executes a full backup. For versions prior to 2.2, this is the only option available. This operation blocks the database.
    • INCREMENTAL_BACKUP Executes an incremental backup. Uses one directory per database. This operation doesn’t block the database.
    • *EXPORT Executes an export of the database in gzipped JSON format, instead of a backup. This operation doesn’t block the database.
  • exportOptions Defines export options to use with that mode. This feature was introduced in version 2.2.
  • delay Defines the delay time. Supports the following suffixes:
    • ms Delay measured in milliseconds.
    • s Delay measured in seconds.
    • m Delay measured in minutes.
    • h Delay measured in hours.
    • d Delay measured in days.
  • firstTime Defines when to initiate the first backup in the schedule. It uses the format of HH:mm:ss in the GMT time zone, on the current day.
  • target.directory Defines the target directory to write backups. By default, it is set to the backup/ directory.
  • target.fileName Defines the target file name. The parameter supports the use of the following variables, (that is, <parameter name="target.filename" value="${DBNAME}-backup.zip"/> produces a mydatabase-backup.zip file).
    • ${DBNAME} Renders the database name.
    • ${DATE} Renders the current date, using the Java DateTime syntax format.
  • db.include Defines in a list the databases to include in the automatic backups. If left empty, it backs up all databases.
  • db.exclude Defines in a list the databases to exclude from automatic backups.
  • bufferSize Defines the in-memory buffer sizes to use in compression. By default it is set to 1MB. Larger buffers mean faster backups, but use more RAM. This feature was introduced in version 1.7.
  • compressionLevel Defines the compression level for the resulting ZIP file. By default, it is set to the maximum level of 9. Set it to a lower value if you find that the backup takes too much time.