dokku / dokku-mongo

a mongo plugin for dokku
MIT License
174 stars 32 forks source link

Difficulties with mongorestore #141

Closed alancwoo closed 3 years ago

alancwoo commented 3 years ago

Description of problem

I am trying to use mongorestore to import a database exported via mongodump on my local dev machine to a dokku instance. I cannot seem to find a way to get this to work.

How reproducible

Persistent

Steps to Reproduce

  1. Export database locally: mongodump --db=DBNAME
  2. Copy resulting dump folder to dokku host
  3. Attempt to import

Actual Results

https://github.com/dokku/dokku-mongo/issues/76#issuecomment-269868348 results in error reading database: not authorized on APP_NAME_REDACTED to execute command

mongorestore --uri='DSN_VIA_MONGO_INFO' hangs with no output

mongorestore --host=MONGO_INFO_INTERNAL_IP --port=MONGO_INFO_PORT --username=USERNAME_FROM_DSN --authenticationDatabase admin --db DB_NAME fails with Failed: error connecting to db server: server returned error on SASL authentication step: Authentication failed.

dokku mongo:import APP_NAME < ./dump/DB_NAME/COLLECTION.bson fails of course, Failed: gzip: invalid header

Expected Results

Import completes successfully

Environment Information

dokku mongo:info APP_NAME output

=====> api-dev mongo service information
       Config dir:          /var/lib/dokku/services/mongo/APP_NAME/config
       Data dir:            /var/lib/dokku/services/mongo/APP_NAME/data
       Dsn:                 mongodb://APP_NAME:APP_PASS@APP_DOMAIN:27017/DB_NAME
       Exposed ports:       -
       Id:                  APP_ID
       Internal ip:         172.17.0.2
       Links:               APP_LINKS
       Service root:        /var/lib/dokku/services/mongo/APP_NAME
       Status:              running
       Version:             mongo:3.6.15

How (deb/make/rpm) and where (AWS, VirtualBox, physical, etc.) was Dokku installed?:

CLI install

josegonzalez commented 3 years ago

The mongodb dump is generated with the following arguments:

--gzip --archive

You'll also need to ensure the database names match locally and remotely, as permissions are only set on the database matching the service name.

Hope that helps.

alancwoo commented 3 years ago

This helped enormously - and worked perfectly, thank you for the help @josegonzalez and everyone for Dokku