4
votes

I used mongodump to backup my database since I want to move it from being hosted at compose.io to being hosted locally in the server itself using mupx.

Once I setup the app and have it running, how can I restore the mongodump? I am using mupx, and when I ssh into the server I see that mongodb is inside a docker container.

What are the steps needed to use mongorestore given that I can copy the mongodump files from my local pc to the server.

1) Use scp command to copy the mongodump folder from my local pc to the server 2) SSH into the server

At this point I am logged into the server and am in the same directory as the dump folder. Mongodb is running inside docker. How can I use mongorestore to restore mongodb to the data in the dump folder?

2

2 Answers

5
votes

I figured out how to do it. Here are step by step instructions.

Here are the instructions

1) Copy dump folder to server

scp -r /local_path/to/dump_folder [email protected]:/remote/path

2) SSH into server

ssh [email protected]

3) Copy from root of server to inside docker container

docker cp dump_folder mongodb:/dump_folder

4) Go into mongodb docker container

docker exec -it mongodb bash

5) check if copied folder exists

ls (you should see dump_folder, if you named it the same folder as in this example)

6) use mongorestore

mongorestore --drop -d AppName dump_folder
0
votes

For example: you copied mongo dump file to /data folder of server.

While you run docker container, you can mount /data folder into docker container.

docker run -v /data:/var/lib/mongodb -p 27017 .... 

After that, you access to inside docker container and go to /var/lib/mongodb. You can see mongo dump file here by using : ls command. Here, you can use mongorestore to restore mongo data.