<p>I made a local backup of my mongodb (version 4) by doing</p>
<pre><code>mongodump -u adminUser --authenticationDatabase admin --gzip --archive=/tmp/file.gz --db &lt;dbname&gt;
</code></pre>
<p>Now I would like to restore this data to my remote mongodb, which is a replicaset with two replicas running on a kubernetes cluster.</p>
<p>Normaly I would use</p>
<pre><code>mongorestore -u adminUser --authenticationDatabase admin --gzip --archive=/tmp/file.gz
</code></pre>
<p>But how do I do this restore on a replicaset architecture?</p>
<p>Do I have to run a shell on any pod instance?</p>
<pre><code>kubectl exec -it &lt;pod-name&gt; -n mongodb -- bash
</code></pre>

user3142695
<p>You need to connect to a replica set. It needs to be set in connection string uri:</p>
<pre><code>mongorestore --uri=&quot;mongodb://adminUser:password@hostname1,hostname2,hostname3/?authSource=admin&amp;replicaSet=&lt;replSetName&gt;&quot;
</code></pre>
<p>according documentation you can specify the replica set also with <code>--host</code> parameter</p>
<pre><code>mongorestore -u adminUser --authenticationDatabase admin --host=&lt;replSetName&gt;/hostname1,hostname2,hostname3
</code></pre>
<p><code>mongorestore</code> will connect to the PRIMARY member, data is restored into there and then replicated to SECONDARY members.</p>
<p>If you have to restore a lot of data, then consider <a href="https://www.mongodb.com/docs/rapid/tutorial/resync-replica-set-member/#sync-by-copying-data-files-from-another-member" rel="nofollow noreferrer">Sync by Copying Data Files from Another Member</a></p>
