Unlike Mysql, I found it quite challenging trying to sync MongoDB files -
They can not be piped back, since they don\'t send the data to stdout
(If I understand corr
I don't really like to have one database connect to another - IMHO it breaks the separation of environments and makes it complicated to automate such scripts.
My solution is to use the mongo dump/restore which use "dump directories" and to use tar for streaming the files. A trivial implementation (for copying from one remote to another remote) might look like this:
ssh remote1 'mongodump > /dev/null && tar -zc dump && rm -rf dump' | \
ssh remote2 'tar -zx && mongorestore dump && rm -rf dump'
mongodump and mongorestore has very verbose output, but mongodump's will both mess with the tar streaming and also apparently mongodump will actually refuse to work if you run without a pseudo-terminal and without output redirection.mongodump has an option to dump to stdout, but I couldn't figure out what kind of format it uses and I didn't understand how to get mongorestore to load that.