Next question in reference with previous one Where does mongodb store databse in ubuntu?
$ cd /var/lib/mongodb/
$ ls
ihtx.0 ihtx.1 ihtx.ns journal local.0 local.ns mongod.lock
Here, I can see ihtx.0 ihtx.1 ihtx.ns
three files with the same name. Here which one is mydatabase which I usually see in mongo shell?
which one should I dump ?
Tried each, getting following error :
$ mongodump --dbpath /var/lib/mongodb/ihtx.XX --out /home/user/Desktop/
If you are running a mongod on the same path you should connect to that instead of direct data file access
Thu Mar 13 11:17:21.123 dbexit:
Thu Mar 13 11:17:21.123 [tools] shutdown: going to close listening sockets...
Thu Mar 13 11:17:21.123 [tools] shutdown: going to flush diaglog...
Thu Mar 13 11:17:21.123 [tools] shutdown: going to close sockets...
Thu Mar 13 11:17:21.123 [tools] shutdown: waiting for fs preallocator...
Thu Mar 13 11:17:21.123 [tools] shutdown: closing all files...
Thu Mar 13 11:17:21.123 [tools] closeAllFiles() finished
Thu Mar 13 11:17:21.123 [tools] shutdown: removing fs lock...
Thu Mar 13 11:17:21.123 [tools] couldn't remove fs lock errno:9 Bad file descriptor
Thu Mar 13 11:17:21.123 dbexit: really exiting now
This command will work for you If your dbpath is set or you mongoDB service is Running here ihtx denotes your dbname
$ mongodump -d ihtx --out /home/user/Desktop/intxDB