Automatic Backup Server Plugin
Using this server plugin, OrientDB executes regular backups on the databases. It implements the Java class:
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:
<!-- AUTOMATIC BACKUP, TO TURN ON SET THE 'ENABLED' PARAMETER TO 'true' -->
<handler class="com.orientechnologies.orient.server.handler.OAutomaticBackup">
<parameters>
<parameter name="enabled" value="false"/>
<!-- LOCATION OF JSON CONFIGURATION FILE -->
<parameter name="config" value="${ORIENTDB_HOME}/config/automatic-backup.json"/>
</parameters>
</handler>
This section tells the OrientDB server to read the file at $ORIENTDB_HOME/config/automatic-backup.json for the automatic backup configuration.
{
"enabled": true,
"mode": "FULL_BACKUP",
"exportOptions": "",
"delay": "4h",
"firstTime": "23:00:00",
"targetDirectory": "backup",
"targetFileName": "${DBNAME}-${DATE:yyyyMMddHHmmss}.zip",
"compressionLevel": 9,
"bufferSize": 1048576
}
"enabled"Defines whether it uses automatic backups. The supported values are:trueEnables automatic backups.falseDisables 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. This is available only in the Enterprise Edition. It 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:msDelay measured in milliseconds.sDelay measured in seconds.mDelay measured in minutes.hDelay measured in hours.dDelay measured in days.
"firstTime"Defines when to initiate the first backup in the schedule. It uses the format ofHH:mm:ssin the GMT time zone, on the current day."targetDirectory"Defines the target directory to write backups. By default, it is set to thebackup/directory."targetFileName"Defines the target filename. This parameter supports the use of the following variables, (that is,"${DBNAME}-backup.zip"producesmydatabase-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 to1MB. 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 of9. 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.
<!-- AUTOMATIC BACKUP, TO TURN ON SET THE 'ENABLED' PARAMETER TO 'true' -->
<handler class="com.orientechnologies.orient.server.handler.OAutomaticBackup">
<parameters>
<parameter name="enabled" value="false" />
<!-- CAN BE: FULL_BACKUP, INCREMENTAL_BACKUP, EXPORT -->
<parameter name="mode" value="FULL_BACKUP"/>
<!-- OPTION FOR EXPORT -->
<parameter name="exportOptions" value=""/>
<parameter name="delay" value="4h" />
<parameter name="target.directory" value="backup" />
<!-- ${DBNAME} AND ${DATE:} VARIABLES ARE SUPPORTED -->
<parameter name="target.fileName" value="${DBNAME}-${DATE:yyyyMMddHHmmss}.zip" />
<!-- DEFAULT: NO ONE, THAT MEANS ALL DATABASES.
USE COMMA TO SEPARATE MULTIPLE DATABASE NAMES -->
<parameter name="db.include" value="" />
<!-- DEFAULT: NO ONE, THAT MEANS ALL DATABASES.
USE COMMA TO SEPARATE MULTIPLE DATABASE NAMES -->
<parameter name="db.exclude" value="" />
<parameter name="compressionLevel" value="9"/>
<parameter name="bufferSize" value="1048576"/>
</parameters>
</handler>
enabledDefines whether it uses automatic backups. Supported values are:trueEnables automatic backups.falseDisables automatic backups. This is the default setting.
mode/>Defines the backup mode. Supported values are:FULL_BACKUPExecutes a full backup. For versions prior to 2.2, this is the only option available. This operation blocks the database.INCREMENTAL_BACKUPExecutes an incremental backup. Uses one directory per database. This operation doesn't block the database.- *
EXPORTExecutes an export of the database in gzipped JSON format, instead of a backup. This operation doesn't block the database.
exportOptionsDefines export options to use with that mode. This feature was introduced in version 2.2.delayDefines the delay time. Supports the following suffixes:msDelay measured in milliseconds.sDelay measured in seconds.mDelay measured in minutes.hDelay measured in hours.dDelay measured in days.
firstTimeDefines when to initiate the first backup in the schedule. It uses the format ofHH:mm:ssin the GMT time zone, on the current day.target.directoryDefines the target directory to write backups. By default, it is set to thebackup/directory.target.fileNameDefines the target file name. The parameter supports the use of the following variables, (that is,<parameter name="target.filename" value="${DBNAME}-backup.zip"/>produces amydatabase-backup.zipfile).${DBNAME}Renders the database name.${DATE}Renders the current date, using the Java DateTime syntax format.
db.includeDefines in a list the databases to include in the automatic backups. If left empty, it backs up all databases.db.excludeDefines in a list the databases to exclude from automatic backups.bufferSizeDefines the in-memory buffer sizes to use in compression. By default it is set to1MB. Larger buffers mean faster backups, but use more RAM. This feature was introduced in version 1.7.compressionLevelDefines the compression level for the resulting ZIP file. By default, it is set to the maximum level of9. Set it to a lower value if you find that the backup takes too much time.