Answers:
要还原单个数据库,您需要在mongorestore命令行中提供转储目录的路径。
例如:
# Backup the training database
mongodump --db training
# Restore the training database to a new database called training2
mongorestore --db training2 dump/training
在--db对选项mongodump指定源数据库转储。
在--db对选项mongorestore指定目标数据库恢复到。
mongodump以及所使用的确切命令行吗?该--archive命令创建一种不同于的特殊存档格式--gzip。根据您使用的mongodump版本和命令行选项,使用重命名数据库或集合有不同的建议mongorestore。
$ mongorestore --drop -d <database-name> <dir-of-backup-files>
--drop 如果要替换现有数据库,则必须删除-d <database-name> 要创建/替换的数据库的名称<dir-of-backup-files> 由于某些原因,即使它是当前目录,这也是必要的参考:https://coderwall.com/p/3hx06a/restore-a-mongodb-database-mongorestore
mongodump --archive创建.gz文件。我可以知道如何从.gz文件还原并指定新的数据库名称吗?我的.gz文件大小为2Gb,因此提取它非常耗时。