dokku/dokku-mongo

Difficulties with mongorestore

alancwoo opened this issue · 2 comments

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

#76 (comment) 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

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.

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