<p>I have created a mongodb pod in my Minikube local cluster with the following configuration, now I would like to migrate the data of my existing mongodb database(run in AWS EC2 instance) to this database, how can I accomplish this?</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: mongodb
  labels:
    app: mongodb
spec:
  volumes:
  - name: mongo-vol
    persistentVolumeClaim:
      claimName: mongo-pvc
  containers:
  - image: mongo
    name: container1
    command:
      - &quot;mongod&quot;
      - &quot;--bind_ip&quot;
      - &quot;0.0.0.0&quot;

    ports:
    - containerPort: 27017
    volumeMounts:
    - name: mongo-vol
      mountPath: /data/db
</code></pre>

efgdh
<p>Can't added a comment because I do not have more than 50 reputation but here is the thing:</p>
<ul>
<li>You created a Pod using MongoDB and I see the volumeMount set to /data/db. What is this path? Is this volume a hostPath, NFS, external storage?</li>
</ul>
<p>The migration itself could be accomplished in two ways:</p>
<ol>
<li>by running a mongodump on your EC2 instance:</li>
</ol>
<pre><code>mongodump -host hostname --port 27017 --out /tmp/mongodb-dump
</code></pre>
<p>Then a mongorestore on your /data/db path.</p>
<ul>
<li>You can manually log in on the pod</li>
</ul>
<pre><code>#copy your dump from host to pod using
kubectl cp /tmp/foo_dir &lt;some-pod&gt;:/tmp/bar_dir

#log on the pod 
kubectl exec mongodb -it /bin/bash

#run restore
mongorestore /tmp/mongodb-dump
</code></pre>
<p>or</p>
<ol start="2">
<li>You can copy all files/the entire /data from your EC2 instance and dropped on the volumeMount your pod is mounting /data/db.</li>
</ol>
