Search code examples
mongodbmongodump

Backup mongodb directly to remote server


Is there a way to save mongodump archive directly on remote machine (via ssh or rsync) without saving in locally? I see --out option in docs but no suitable examples


Solution

  • If you do not specify the name of the --archive, it will just go to stdout, where you catch it via | ssh. This is work for me

    mongodump --db dbname --gzip  --archive | ssh user@remotehost "cat > /path/to/dump.gz"
    

    Or

    mongodump --db dbname  --archive | gzip -c | ssh user@remotehost "cat > /path/to/dump.gz"