代码之家  ›  专栏  ›  技术社区  ›  PPP

mongorestore文件X没有.bson扩展名

  •  0
  • PPP  · 技术社区  · 5 年前

    我试图通过docker运行mongorestore,将数据库还原到系统上另一个停靠的mongo:

    sudo docker run --net=host -v $PWD:/home/mongo mongo /bin/bash -c "mongorestore -d venko /home/mongo/mongo_venko_20200326230306.archive"
    

    但我明白

    2020-03-27T00:17:32.645+0000    the --db and --collection args should only be used when restoring from a BSON file. Other uses are deprecated and will not exist in the future; use --nsInclude instead
    2020-03-27T00:17:32.645+0000    Failed: file /home/mongo/mongo_venko_20200326230306.archive does not have .bson extension
    2020-03-27T00:17:32.645+0000    0 document(s) restored successfully. 0 document(s) failed to restore.
    

    答案来自 mongorestore error: Don't know what to do with the dump file 告诉我传递-db选项,但我确实通过了,所以我不知道该怎么办。

    0 回复  |  直到 5 年前
        1
  •  10
  •   Đỗ Công Bằng    3 年前

    我必须使用这两个选项 --gzip --存档

    mongorestore --uri="uri" --gzip --archive=/Path/to/archive/abc.gz
    
        2
  •  0
  •   Mushahid Khan    3 年前

    正如错误所述,mongorestore会查找BSON文件,而存档不是它要查找的扩展名。

    您可以执行以下操作:

    1. 使用:

      mongorestore--gzip/home/mongo/mongo_venko20200326230306.存档

    2. 或者,提取存档文件并使用:

      mongorestore/主页/mongo/mongo_venko_20200326230306/lt;文件名.bson>