如何在我的mongdb容器被删除后恢复mongodb数据

我在Docker容器中运行mongodb ,并且有数据文件备份。

但是今天我删除了我的粗心大意。

我试图运行另一个容器,并将数据文件放入容器,但它不起作用。

我怎样才能从数据文件恢复我的数据?

数据库文件我现在只有: 在这里输入图像说明

我使用的容器是tutum / mongodb.my docker-compose.yml文件

mongo_db: image: tutum/mongodb privileged: true restart: always ports: - 27016:27017 - 28016:28017 volumes: - /var/mongodb:/data/db environment: - MONGODB_PASS=xxxxxx - AUTH=yes

现在我想从dirctory / var / mongodb中恢复我的数据到我的新容器

我把文件除了mongod.lock在我的新容器,但我的mongodb无法运行。 这是截图: 在这里输入图像说明

mongod.conf是:

 # Where to store the data. # Note: if you run mongodb as a non-root user (recommended) you may # need to create and set permissions for this directory manually, # eg, if the parent directory isn't mutable by the mongodb user. dbpath=/var/lib/mongodb #where to log logpath=/var/log/mongodb/mongod.log logappend=true #port = 27017 # Listen to local interface only. Comment out to listen on all interfaces. bind_ip = 127.0.0.1 # Disables write-ahead journaling # nojournal = true # Enables periodic logging of CPU utilization and I/O wait #cpu = true # Turn on/off security. Off is currently the default #noauth = true #auth = true # Verbose logging output. #verbose = true # Inspect all client data for validity on receipt (useful for # developing drivers) #objcheck = true # Enable db quota management #quota = true # Set oplogging level where n is # 0=off (default) # 1=W # 2=R # 3=both # 7=W+some reads #diaglog = 0 # Ignore query hints #nohints = true # Enable the HTTP interface (Defaults to port 28017). #httpinterface = true # Turns off server-side scripting. This will result in greatly limited # functionality #noscripting = true # Turns off table scans. Any query that would do a table scan fails. #notablescan = true # Disable data file preallocation. #noprealloc = true # Specify .ns file size for new databases. # nssize = <size> # Replication Options # in replicated mongo databases, specify the replica set name here #replSet=setname # maximum size in megabytes for replication operation log #oplogSize=1024 # path to a key file storing authentication info for connections # between replica set members #keyFile=/path/to/keyfile 

当容器开始运行容器的环境时,在env中的容器集合STORAGE_ENGINE是:

 # mongod.conf STORAGE_ENGINE=wiredTiger HOSTNAME=bb544551ec2b MONGODB_PASS=xxxxxx LS_COLORS= AUTH=yes PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PWD=/etc SHLVL=1 HOME=/root LESSOPEN=| /usr/bin/lesspipe %s JOURNALING=yes LESSCLOSE=/usr/bin/lesspipe %s %s _=/usr/bin/env OLDPWD=/ 

tutum / mongodb下的日志:3.0:

tutum / mongodb下的日志:3.0

这取决于您如何执行备份。

1 – 你拿了一个文件系统快照。
=>你可以解开你的数据文件夹中的快照(检查mongod.conf中的数据文件夹的位置)。

2 – 您使用了mongodump命令。
=>你需要使用mongorestore命令