1

Bonjour, I want to mongorestore a dump from an azure VM toward a cosmosDB account. I can do it from command line with stg like this :

mongorestore --host <url>:10255 -u <secret> -p <secret> --ssl --sslAllowInvalidCertificates ./dump/ --numInsertionWorkersPerCollection 40 --batchSize 2

but I can't do it within :

>>> os.execvp('mongorestore',['-h <url>:10255 -u <secret> -p <secret> --ssl --sslAllowInvalidCertificates ./dump/ --numInsertionWorkersPerCollection 40 --batchSize 2'])
2018-12-14T12:31:29.163+0000    Failed: error connecting to db server: no reachable servers

or even in a most modern way, with subprocess, same thing :(

1 Answer 1

1

I tried to realize your needs using Python 3.6 on my local machine, and my sample code works fine as below, which use the subprocess.Popen method.

Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> subprocess.Popen('mongorestore --host 127.0.0.1:27017 ./dump/ --numInsertionWorkersPerCollection 40 --batchSize 2')
<subprocess.Popen object at 0x0000025E2D9B0AC8>
>>> 2018-12-19T14:56:40.687+0800        preparing collections to restore from
2018-12-19T14:56:40.688+0800    done

Or to use os.popen also works as same as subprocess.Popen.

>>> import os
>>> os.popen('mongorestore --host 127.0.0.1:27017 ./dump/ --numInsertionWorkersPerCollection 40 --batchSize 2')
<os._wrap_close object at 0x0000025E2D9BE5C0>
>>> 2018-12-19T15:00:55.372+0800        preparing collections to restore from
2018-12-19T15:00:55.373+0800    done

Hope it helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.