DjangoRocks
DjangoRocks

Reputation: 14198

Merging mongodb files in different location

May i know how do i merge my mongodb data files?

The following is my current situation:

At /data/db:

drwxr-xr-x 3 root root      4096 2011-03-15 06:38 .
drwxr-xr-x 3 root root      4096 2011-03-15 00:35 ..
-rwxr-xr-x 1 root root         5 2011-03-15 06:54 mongod.lock
drwxr-xr-x 2 root root      4096 2011-03-15 00:43 social_scraper
-rw------- 1 root root  67108864 2011-03-15 06:39 social_scraper.0
-rw------- 1 root root 134217728 2011-03-15 06:38 social_scraper.1
-rw------- 1 root root  16777216 2011-03-15 06:39 social_scraper.ns

At /var/lib/mongodb :

drwxr-xr-x  5 mongodb mongodb      4096 2011-03-15 07:06 .
drwxr-xr-x 46 root    root         4096 2011-03-10 09:40 ..
-rwxr-xr-x  1 root    root            0 2011-03-15 07:06 mongod.lock
drwxr-xr-x  2 root    root         4096 2011-03-15 07:06 social_scraper
-rw-------  1 root    root     67108864 2011-03-15 07:06 social_scraper.0
-rw-------  1 root    root    134217728 2011-03-15 07:06 social_scraper.1
-rw-------  1 root    root     16777216 2011-03-15 07:06 social_scraper.ns

How do i merge all of the records into /data/db or /var/lib/mongodb ?

The above records ( in both directories ) have been restored using mongod --repair

It will be great if specific steps can be given as I am quite a newbie when it comes to MongoDB maintainence.

I'm using ubuntu 10.04 server edition, MongoDB v1.6.5.

Best Regards.

Upvotes: 1

Views: 1049

Answers (1)

Andrew Orsich
Andrew Orsich

Reputation: 53685

You can use mongodump to move files from first database in bson files, and than use mongoimport to import dumped files into another database:

mongodump.exe --host localhost:27020 --db dbName

mongorestore.exe --host localhost:27020 --db secondDBName folderWithBsonFiles

Upvotes: 4

Related Questions