Transfer MongoDB collection to Windows

A quick’n’dirty1 way for transfering MongoDB collection from Linux to Windows, using plink as the ssh client.

plink -load null username@remotehost ^
mongoexport --db mydb --collection mycollection | ^
mongoimport --db mydb --collection mycollection

If you have setup the key based authentication for SSH and are using pageant to manage the key locally, this does not prompt for password. -load null forces plink to ignore the hostname defined in in your default PuTTY session profile.

[1] dirty because mongoexport does not transfer all datatypes, in order to really transfer everything you should create the export with mongodump.