From 71817137cd0f64088a87ef7c323fbf53b17529a1 Mon Sep 17 00:00:00 2001 From: Noah Zalev Date: Wed, 7 Apr 2021 17:27:23 -0400 Subject: [PATCH] Fix for #2486 if dburl then use --uri option --- db.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/db.js b/db.js index 8b456b8d..bf92e090 100644 --- a/db.js +++ b/db.js @@ -1590,10 +1590,13 @@ module.exports.CreateDB = function (parent, func) { var backupPath = parent.backuppath; if (parent.config.settings.autobackup && parent.config.settings.autobackup.backuppath) { backupPath = parent.config.settings.autobackup.backuppath; } try { parent.fs.mkdirSync(backupPath); } catch (e) { } + const dburl = parent.args.mongodb; var mongoDumpPath = 'mongodump'; if (parent.config.settings.autobackup && parent.config.settings.autobackup.mongodumppath) { mongoDumpPath = parent.config.settings.autobackup.mongodumppath; } + var cmd = '"' + mongoDumpPath + '"'; + if (dburl) { cmd = '\"' + mongoDumpPath + '\" --uri=\"' + dburl.replace('?', '/?') + '\"'; } const child_process = require('child_process'); - child_process.exec('"' + mongoDumpPath + '"', { cwd: backupPath }, function (error, stdout, stderr) { + child_process.exec(cmd, { cwd: backupPath }, function (error, stdout, stderr) { try { if ((error != null) && (error != '')) { if (parent.platform == 'win32') {