簡體   English   中英

ArangoDB - 備份和恢復所有數據

[英]ArangoDB - Backup and restore all data

我的目標是創建 arango 數據庫轉儲(包含所有用戶和密碼、權限、數據庫、collections、角色等),然后在另一台 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

然后我將創建的文件夾移動到此服務器 go 上的空 arangodb 服務器:

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

結果與我的預期相去甚遠,我只是在_system數據庫中為root用戶(沒有其他用戶,沒有數據庫)獲得了 collections。

我究竟做錯了什么? 如何進行完整備份和恢復?

提前致謝。

arangorestore需要被告知要將數據恢復到哪個數據庫。 這可以通過提供--server.database選項來實現,其方式與為arangodump所做的方式相同。 如果沒有為--server.database提供任何值,它將默認為_system ,這意味着 arangorestore 的后續調用將分別覆蓋_system數據庫中的先前數據。

如果備份服務器上尚不存在目標數據庫,則可以使用選項--create-database true即時創建它們。 此外,要恢復系統 collections,需要為arangorestore提供選項 --include --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 ,這將大大簡化備份和恢復過程。

要從遠程服務器或本地服務器獲取轉儲,請執行命令

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

要從轉儲中恢復,請執行以下命令

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM