Fix for #2486 if dburl then use --uri option

Fix for #2486 if dburl then use --uri option

Noah Zalev committed Apr 7, 2021 at 17:27 UTC 71817137cd0f64088a87ef7c323fbf53b17529a1
1 file changed +4 -1
db.js
+4 -1
@@ -1590,10 +1590,13 @@ module.exports.CreateDB = function (parent, func) {
1590 var backupPath = parent.backuppath;
1591 if (parent.config.settings.autobackup && parent.config.settings.autobackup.backuppath) { backupPath = parent.config.settings.autobackup.backuppath; }
1592 try { parent.fs.mkdirSync(backupPath); } catch (e) { }
1593 + const dburl = parent.args.mongodb;
1594 var mongoDumpPath = 'mongodump';
1595 if (parent.config.settings.autobackup && parent.config.settings.autobackup.mongodumppath) { mongoDumpPath = parent.config.settings.autobackup.mongodumppath; }
1596 + var cmd = '"' + mongoDumpPath + '"';
1597 + if (dburl) { cmd = '\"' + mongoDumpPath + '\" --uri=\"' + dburl.replace('?', '/?') + '\"'; }
1598 const child_process = require('child_process');
1596 - child_process.exec('"' + mongoDumpPath + '"', { cwd: backupPath }, function (error, stdout, stderr) {
1599 + child_process.exec(cmd, { cwd: backupPath }, function (error, stdout, stderr) {
1600 try {
1601 if ((error != null) && (error != '')) {
1602 if (parent.platform == 'win32') {