How to dump all databases with ArangoDB

久未见 提交于 2019-12-07 12:33:45

问题


I have ArangoDB running locally with databases, collections, data and graphs from several different projects in it. I'd like to back up everything so I can rebuild my system. I know how to do a backup of a single database, but because I have a bunch I'm hoping to do this in one shot.

Essentially, I'm looking for the ArangoDB equivalent of

mysqldump -u root -p --all-databases > alldb.sql

Obviously the ArangoDB equivalent of

mysql -u root -p < alldb.sql

Would be good to know too.


回答1:


As of release 3.3, arangodump does not support dumping all databases at once. It is per database.

To make it dump all databases, it can be invoked in a loop over all databases, e.g.

# loop over all databases
for db in `arangosh --javascript.execute-string "db._databases().forEach(function(db) { print(db); });"` # host, user and password go here...
  do
    arangodump --sever.database "$db" # host, user and password go here...
  done

This will work if there is one user that has access privileges for all databases.




回答2:


While the previous script is almost correct, it won't work with multiple database, since it will start complaining about the dump directory, and asks you to add --overwrite true to the command. This won't work as well, since it'll only output the latest database.

We use the following script, which is slightly changed from the one from stj's answer (or at least the following is part of the backup procedure) to get a dump of all the databases we have:

USER=...
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 ~/dump/"$db" --overwrite true --server.username "$USER" --server.password "$PASSWORD" --server.database "$db" 
done


来源:https://stackoverflow.com/questions/50615754/how-to-dump-all-databases-with-arangodb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!