if dburl then use --uri option
This commit is contained in:
Noah Zalev 2021-04-07 17:27:23 -04:00
parent a66bd9b595
commit 71817137cd
1 changed files with 4 additions and 1 deletions

5
db.js
View File

@ -1590,10 +1590,13 @@ module.exports.CreateDB = function (parent, func) {
var backupPath = parent.backuppath; var backupPath = parent.backuppath;
if (parent.config.settings.autobackup && parent.config.settings.autobackup.backuppath) { backupPath = parent.config.settings.autobackup.backuppath; } if (parent.config.settings.autobackup && parent.config.settings.autobackup.backuppath) { backupPath = parent.config.settings.autobackup.backuppath; }
try { parent.fs.mkdirSync(backupPath); } catch (e) { } try { parent.fs.mkdirSync(backupPath); } catch (e) { }
const dburl = parent.args.mongodb;
var mongoDumpPath = 'mongodump'; var mongoDumpPath = 'mongodump';
if (parent.config.settings.autobackup && parent.config.settings.autobackup.mongodumppath) { mongoDumpPath = parent.config.settings.autobackup.mongodumppath; } 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'); 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 { try {
if ((error != null) && (error != '')) { if ((error != null) && (error != '')) {
if (parent.platform == 'win32') { if (parent.platform == 'win32') {