i had to update a collection on my local machine and want to upload this to a docker instance, here is my procedure
$ #backup local database
$ mongodump --collection styles --db ccc-mongo
$ tar -zcvf dump.tar.gz dump
$ scp dump.tar.gz me@remote:/home/me
$ ssh me@remote
me@remote: ~ $ docker exec -i mongo-dev sh -c "cd /tmp && tar xzf - && mongorestore --collection styles --db ccc-mongo" < dump.tar.gz
this gives me an error
connected to: 127.0.0.1
Fri Dec 18 16:05:26.768 ERROR: ERROR: root directory must be a dump of a single database
Fri Dec 18 16:05:26.768 ERROR: when specifying a db name with --db
Import BSON files into MongoDB.
i just need to restore one collection without removing the other data, any advice much appreciated
this worked for me
docker exec -i mongo-dev sh -c "cd /tmp && tar xzf - && mongorestore --db ccc-mongo --drop dump/ccc-mongo && rm -Rf dump" < dump.tar.gz
need to make sure in the dump to just include the collection i want to restore only
I figured out how to do it
NOTE: please explain your question briefly. Question is not clear, please specify where you want to mondodump and restore your data - into server database or your ubuntu running computer. If into server from your local database then follow following steps:-
Here are the instructions
Copy dump folder to server
scp -r /local_path/to/dump_folder root@111.222.33.4:/remote/path
SSH into server
ssh root@111.222.33.4
Copy from root of server to inside docker container
docker cp dump_folder mongodb:/dump_folder
Go into mongodb docker container
docker exec -it mongodb bash
check if copied folder exists
ls
(you should see dump_folder, if you named it the same folder as in this example)
use mongorestore
mongorestore --drop -d AppName dump_folder