Reputation: 23593
I have an Ubuntu 16.04.3 x64 droplet on digital ocean. How can I import a database from my the filesystem on my local machine?
My app is built with Meteor. The following when ran from my app's folder locally works:
mongorestore --port=3001 ../dump
Ive tried SSHing into the server
ssh root@<my servers IP>
And then running the same command:
mongorestore --port=3001 /Users/<my username>/Projects/<project name>/dump
But I get an error:
The program 'mongorestore' is currently not installed. You can install it by typing:
apt install mongodb-clients
So I tried entering mongod:
docker exec -it mongodb mongo nomad
And I get a sucsess message:
MongoDB shell version v3.4.1
connecting to: mongodb://127.0.0.1:27017/nomad
MongoDB server version: 3.4.1
And I try the same command:
mongorestore --port=3001 /Users/<my username>/Projects/<project name>/dump
And I get this error:
2018-01-13T12:30:25.134+0000 E QUERY [main] SyntaxError: missing ; before statement @(shell):1:15
Upvotes: 1
Views: 595
Reputation: 7777
mongorestore
is a shell command, you run it from bash. The mongoshell you ran has a limited syntax, so it won't work like that.
You can try something like this:
docker exec -it mongodb mongorestore /Users/<my username>/Projects/<project name>/dump
The problem is that the project dump you are trying to load is not available to the docker instance, as its file system is isolated from the host server. You could copy the files into the docker instance using docker cp
, and then load them, but it starts getting messy to do, and docker containers are not really designed to be used this way. The docker container usually only has minimal tools available, and you end up needing to install additional software in order to do these kinds of operations. It then becomes a non standard container, and can't be replaced.
It might be time for you to move to a separate database server, which can be done by using a service such as mlab, or you can create your own droplet to host a mongodb server. Using a service gives you tools that you can easily take backup copies, copy one database to another, restore backups etc using a web control panel. Much easier to do.
Upvotes: 1