Orientdb 简明教程

OrientDB - Backup Database

与 RDBMS 一样,OrientDB 也支持备份和还原操作。在执行备份操作时,它会使用 ZIP 算法将当前数据库的所有文件压缩为 zip 格式。可以通过启用 Automatic-Backup 服务器插件自动使用此功能(备份)。

Like RDBMS, OrientDB also supports the backup and restore operations. While executing the backup operation, it will take all files of the current database into a compressed zip format using the ZIP algorithm. This feature (Backup) can be availed automatically by enabling the Automatic-Backup server plugin.

备份数据库或导出数据库是相同的,但是,根据过程,我们必须知道何时使用备份以及何时使用导出。

Taking backup of a database or exporting a database is the same, however, based on the procedure we have to know when to use backup and when to use export.

在进行备份时,它将创建一个数据库的一致副本,所有进一步的写操作都会被锁定并等待完成备份过程。在此操作中,它将创建一个只读备份文件。

While taking backup, it will create a consistent copy of a database, all further write operations are locked and waiting to finish the backup process. In this operation, it will create a read-only backup file.

如果你在进行备份时需要并发读写操作,你必须选择导出数据库而不是备份数据库。导出不会锁定数据库,并在导出过程中允许并发写入。

If you need the concurrent read and write operation while taking a backup you have to choose exporting a database instead of taking backup of a database. Export doesn’t lock the database and allows concurrent writes during the export process.

以下语句是数据库备份的基本语法。

The following statement is the basic syntax of database backup.

./backup.sh <dburl> <user> <password> <destination> [<type>]

以下是上文中选项的详细信息。

Following are the details about the options in the above syntax.

<dburl> − 位于本地或远程位置的数据库 URL,其中包含数据库。

<dburl> − The database URL where the database is located either in the local or in the remote location.

<user> − 指定运行备份的用户名。

<user> − Specifies the username to run the backup.

<password> − 提供特定用户的密码。

<password> − Provides the password for the particular user.

<destination> − 目标文件位置,指定存储备份 zip 文件的位置。

<destination> − Destination file location stating where to store the backup zip file.

<type> − 可选的备份类型。它有以下两个选项之一。

<type> − Optional backup type. It has either of the two options.

  1. Default − locks the database during the backup.

  2. LVM − uses LVM copy-on-write snapshot in background.

Example

备份 demo 数据库(位于 local file system /opt/orientdb/database/demo 中)到一个名为 sample-demo.zip 的文件,并将其放在当前目录中。

Take a backup of the database demo which is located in the local file system /opt/orientdb/databases/demo into a file named sample-demo.zip and located into the current directory.

你可以使用以下命令备份数据库 demo。

You can use the following command to take a backup of the database demo.

$ backup.sh plocal: opt/orientdb/database/demo admin admin ./backup-demo.zip

Using Console

你也可以使用 OrientDB 控制台完成该操作。在备份特定数据库之前,你必须首先连接到数据库。你可以使用以下命令连接到名为 demo 的数据库。

The same you can do using the OrientDB console. Before taking the backup of a particular database, you have to first connect to the database. You can use the following command to connect to the database named demo.

orientdb> CONNECT PLOCAL:/opt/orientdb/databases/demo admin admin

连接之后,你可以使用以下命令将数据库备份到当前目录中的名为“backup-demo.zip”的文件中。

After connecting you can use the following command to take backup of the database into a file named ‘backup-demo.zip’ in the current directory.

orientdb {db=demo}> BACKUP DATABASE ./backup-demo.zip

如果此命令成功执行,你将收到一些成功通知以及以下消息。

If this command is executed successfully, you will get some success notifications along with following message.

Backup executed in 0.30 seconds