title: Sync MongoDB Via ssh
body: <p>Unlike Mysql, I found it quite challenging trying to sync MongoDB files -<br>
  They can not be piped back, since they don't send the data to stdout<br>
  (If I understand correctly).</p>
  
  <p>So, I'm trying to find another way, that doesn't involve two ssh calls.<br>
  What needs to be done is this:</p>
  
  <ul>
  <li>Log into the ssh server</li>
  <li>Export all MongoDB files</li>
  <li>Compress them to gzip</li>
  <li>Send them back to the local machine</li>
  <li>Extract and import</li>
  </ul>
  
  <p>The key thing here, though, is leaving no trace behind -<br>
  I don't want the compressed files stay in the remote machine,<br>
  which would usually require me for another ssh login.<br>
  So something along the lines of "move files into archive" is the ideal solution,<br>
  if that could be later piped back to the local machine seamlessly.</p>
  
  <p>I realize MongoDB has a method to connect to a server credentials using mongodump, but the port is closed atm, so I need the SSH method.
  Any other ideas would be welcome, BTW.</p>
  
  <h1>Edit - 11.06.14</h1>
  
  <p>Since this questions seems to be somewhat popular, I'd care to share a script that evolved from this questions' answers, and other resources during the last year (credit is where credit is due).<br>
  The script basically manages a sync from/to a remote server, for either type of db possible (probably. postgres, mysql and mongo for the time being).<br>
  It does have a few assumptions, like the root user having no password for the db, but that can be changed according to need.</p>
  
  <p>The script can be found here: <a href="https://github.com/iwfmp/zsh/blob/master/scripts/db/db-sync">https://github.com/iwfmp/zsh/blob/master/scripts/db/db-sync</a></p>