Restoring Mongodb from a filesystem snapshot

Hi,

Does anyone know if restoring from the filesystem snapshot that looks like below is possible?
I copied the contents of the dbpath (/data/db) to a different directory. As the size of the database was not big, I made a copy of the directory. The mongodb running it was an older version, and I’m not sure which one.

Now I only have these files and hoping to recover what is inside. The journal directory looks empty.

When I connect it and check the databases, I see only ‘admin’, ‘config’, and ‘local’.
The files locall.0 and local.ns has size 64M and 16M respectively and it looks like the data is in there. Do you think I can recover the data?

Thank you for your help in advance!

**hjk@ops**:**/ops/mongodb-backup/db**$ ls -lh

total 80M

drwxr-xr-x 2 hjk hjk 10 Nov 29 15:30 **_tmp**

drwxr-xr-x 2 hjk hjk 10 Nov 29 15:30 **journal**

-rw-r--r-- 1 hjk root 64M Nov 29 15:31 local.0

-rw-r--r-- 1 hjk root 16M Nov 29 15:31 local.ns

-rwxr-xr-x 1 hjk hjk 0 Nov 29 15:31 **mongod.lock**

Hi @trinity_hj welcome to the community!

That directory content curiously look similar to a fresh MongoDB 2.6 installation:

❯ ls -lh
total 32856
drwxr-xr-x  2 xxx  yyy    64B  9 Feb 12:35 _tmp
drwxr-xr-x  3 xxx  yyy    96B  9 Feb 12:35 journal
-rw-------  1 xxx  yyy    64M  9 Feb 12:35 local.0
-rw-------  1 xxx  yyy    16M  9 Feb 12:35 local.ns
-rwxr-xr-x  1 xxx  yyy     6B  9 Feb 12:35 mongod.lock

As you can see the sizes are exactly the same as well. This is a fresh totally empty MongoDB 2.6 deployment using the discontinued MMAPv1 storage engine that’s not supported anymore and has been removed from MongoDB. If there are data in the database, you should see a lot more files than this. Thus, I’m not sure if there’s anything to recover.

Best regards
Kevin

3 Likes