I'm trying to dump a MongoDB collection from a remote server to a local JSON file.
First, I do some ssh port forwarding to begin with:
ssh -NL 12345:localhost:27017 $REMOTE_USERNAME@$REMOTE_HOST &
Then, the export itself:
mongoexport -h $MONGODB_URL -d $MONGODB_DBNAME -c $MONGODB_COLLECTION -o $BACKUP_FILE --pretty
What I would normally get is something like this:
2019-02-07T14:58:15.322-0400 writing bubeIO.requests to
2019-02-07T14:58:18.754-0400 [........................] bubeIO.requests 0/2773 (0.0%)
2019-02-07T14:58:21.754-0400 [........................] bubeIO.requests 10/2773 (0.3%)
2019-02-07T14:58:24.754-0400 [........................] bubeIO.requests 20/2773 (0.6%)
...
...
2019-02-07T14:59:00.754-0400 [........................] bubeIO.requests 2773/2773 (100.0%)
But, what I'm getting is this:
2019-02-07T14:58:15.322-0400 writing bubeIO.requests to
2019-02-07T14:58:18.754-0400 [........................] bubeIO.requests 0/2773 (0.0%)
2019-02-07T14:58:21.754-0400 [........................] bubeIO.requests 0/2773 (0.0%)
2019-02-07T14:58:24.754-0400 [........................] bubeIO.requests 0/2773 (0.0%)
2019-02-07T14:58:27.753-0400 [........................] bubeIO.requests 101/2773 (3.6%)
2019-02-07T14:58:30.753-0400 [........................] bubeIO.requests 101/2773 (3.6%)
2019-02-07T14:58:33.754-0400 [........................] bubeIO.requests 101/2773 (3.6%)
2019-02-07T14:58:36.753-0400 [........................] bubeIO.requests 101/2773 (3.6%)
2019-02-07T14:58:39.753-0400 [........................] bubeIO.requests 101/2773 (3.6%)
2019-02-07T14:58:42.753-0400 [........................] bubeIO.requests 101/2773 (3.6%)
2019-02-07T14:58:45.754-0400 [........................] bubeIO.requests 101/2773 (3.6%)
2019-02-07T14:58:48.753-0400 [........................] bubeIO.requests 101/2773 (3.6%)
2019-02-07T14:58:51.753-0400 [........................] bubeIO.requests 101/2773 (3.6%)
2019-02-07T14:58:54.754-0400 [........................] bubeIO.requests 101/2773 (3.6%)
2019-02-07T14:58:57.753-0400 [........................] bubeIO.requests 101/2773 (3.6%)
2019-02-07T14:59:00.594-0400 [........................] bubeIO.requests 101/2773 (3.6%)
2019-02-07T14:59:00.594-0400 Failed: error writing data for collection `bubeIO.requests` to disk: error reading collection: read tcp [::1]:61276->[::1]:12345: use of closed network connection
As you can see, it goes from 0 to 101 real quick and then it doesn't go anywhere from there until timeout.
It worked nicely before for remote dumps and suddenly this starts to happen. Local dumps work just fine, so this could be a networking issue?
Can anyone give me a direction on how to solve this?
PS: mongod and mongoexport are both version 4.0.2
EDIT
It started working again after I freed a total of 13 GB hd space. Maybe the disk could not hold the whole uncompressed collection, so I'm getting deeper in mongoexport's inner workings and disk usage. Thanks to @priyanka-kariya and @Stennie.
Best Answer
Please check the disk space on target machine