【问题标题】:ArangoDB - Backup and restore all dataArangoDB - 备份和恢复所有数据
【发布时间】:2019-05-28 09:17:07
【问题描述】:

我的目标是创建 arango 数据库转储(包含所有用户和密码、权限、数据库、集合、角色等),然后在另一台 arango 服务器上完全恢复这些数据(从划痕和空)。

我使用的是单节点配置,arangodb版本是3.4.4 [linux]

在来源上,我对每个数据库进行转储:

USER=root
PASSWORD=***
for db in $(arangosh --server.username "$USER" --server.password "$PASSWORD" --javascript.execute-string "db._databases().forEach(function(db) { print(db); });")
do
  arangodump --output-directory /tmp/dump/"$db" --overwrite true --server.username "$USER" --server.password "$PASSWORD" --include-system-collections --server.database "$db"
done

然后我将创建的文件夹移动到此服务器上的空 arangodb 服务器上:

arangorestore --input-directory "/tmp/dump/_system/"
arangorestore --input-directory "/tmp/dump/collection/"
arangorestore --input-directory "/tmp/dump/collection2/"
...one by one 

结果如果超出我的预期,我只是在 _system 数据库中为 root 用户(没有其他用户,没有数据库)获取集合。

我做错了什么?如何进行完整备份和还原?

提前致谢。

【问题讨论】:

    标签: database arangodb database-backups


    【解决方案1】:

    arangorestore 需要被告知要将数据恢复到哪个数据库。这可以通过提供--server.database 选项来实现,方法与为arangodump 提供的方式相同。 如果没有为 --server.database 提供值,它将默认为 _system,这意味着随后的 arangorestore 调用将覆盖 _system 数据库中的先前数据。

    如果备份服务器上尚不存在目标数据库,则可以使用选项--create-database true 即时创建它们。 此外,要恢复系统集合,需要为arangorestore 提供选项--include-system-collections true

    这意味着,如果您的数据库确实被命名为“collection”和“collection2”,那么您的恢复命令应该如下所示:

    arangorestore --input-directory "/tmp/dump/_system/" --server.database "_system" --include-system-collections true --create-database true
    arangorestore --input-directory "/tmp/dump/collection/" --server.database "collection" --include-system-collections true --create-database true
    arangorestore --input-directory "/tmp/dump/collection2/" --server.database "collection2" --include-system-collections true --create-database true
    

    还请注意,在 ArangoDB 3.5 中,arangodump 和 arangorestore 都有一个选项 --all-databases,这将大大简化备份和恢复过程。

    【讨论】:

    • 非常感谢! ArangoDB 3.5 已经发布了吗?没找到
    【解决方案2】:

    要从远程服务器或本地服务器进行转储,请执行命令

    arangodump --server.endpoint tcp://ip_address:8529 --server.username test --server.password test --server.database dev --output-directory "dump"

    要从转储中恢复,请执行以下命令

    rangorestore --server.endpoint tcp://ip_address:8529 --server.username test --server.password test --server.database dev --input-directory "dump"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-07-29
      • 2011-01-11
      • 1970-01-01
      • 2017-08-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多