在浏览了许多小时的互联网后(包括这里的Stackoverflow),来回查看官方MongoDB网站的文档。我仍然没有找到解决方案,为什么我的存档文件没有用以下命令还原
mongorestore --gzip --drop --nsInclude="*" --archive=/./././code/backups/notura-db-1659281356578.gzip -v
我得到以下输出:
2022-07-31T23:55:19.574+0200 using write concern: &{majority false 0}
2022-07-31T23:55:19.606+0200 will listen for SIGTERM, SIGINT, and SIGKILL
2022-07-31T23:55:19.607+0200 connected to node type: standalone
2022-07-31T23:55:19.619+0200 archive format version "0.1"
2022-07-31T23:55:19.619+0200 archive server version "5.0.3"
2022-07-31T23:55:19.619+0200 archive tool version "100.5.1"
2022-07-31T23:55:19.620+0200 preparing collections to restore from
2022-07-31T23:55:19.632+0200 demux finishing (err:<nil>)
2022-07-31T23:55:19.632+0200 received from namespaceChan
2022-07-31T23:55:19.632+0200 restoring up to 4 collections in parallel
2022-07-31T23:55:19.632+0200 building indexes up to 4 collections in parallel
2022-07-31T23:55:19.632+0200 0 document(s) restored successfully. 0 document(s) failed to restore.我没有收到任何错误消息,我的数据库也没有更新。
我正在运行MongoDB 5.0.3社区
任何帮助都是非常感谢的!
阿隆
发布于 2022-08-03 20:01:54
找到解决方案后,您可以在这里看到我对此的讨论:
重要的是要知道数据库名称是否确实正确。如果您没有在MongoDB shell中指定任何数据库(输入mongosh、mongod或mongo) ->使用您的-db-name,并显示dbs (在mongodb中),您将看到存在哪些数据库。创建一个或使用标准的一个是测试。
编写以下内容以转储数据库:mongodump --uri="mongodb://localhost:27017" --db="your-database-name" --gzip --archive=/code/backups/notura-db.gz
在备份文件夹中,将创建notura-db.gz文件。在使用更复杂的方法之前,您可以通过执行mongoexport / mongoimport来查看所有操作是否正确。
若要还原数据,请使用以下命令行命令:mongorestore --drop --gzip --nsInclude="*" --archive=/code/backups/notura-db.gz -v
干杯!
阿隆
https://stackoverflow.com/questions/73187235
复制相似问题