Update db.js

The Slash before the additional parameters inside the mongoDB connectionstring gave us great headaches.
After the AutoBackup initiated it immediately fails as it couldn't find the database with a trailing slash.
Our connectionstring contains information for the local MongoDB User and the authentication DB.
The String looks as follows (user and password have been omitted):
mongodb://{{user}}:{{password}}@localhost:27017/meshcentral?authSource=admin&compressors=zlib&gssapiServiceName=mongodb
This commit is contained in:
Fabian G 2021-05-19 10:15:32 +02:00 committed by GitHub
parent eb160fa583
commit 5cc23d960e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

4
db.js
View File

@ -1656,7 +1656,7 @@ module.exports.CreateDB = function (parent, func) {
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 + '"'; var cmd = '"' + mongoDumpPath + '"';
if (dburl) { cmd = '\"' + mongoDumpPath + '\" --uri=\"' + dburl.replace('?', '/?') + '\"'; } if (dburl) { cmd = '\"' + mongoDumpPath + '\" --uri=\"' + dburl + '\"'; }
cmd += (parent.platform == 'win32') ? ' --archive=\"nul\"' : ' --archive=\"/dev/null\"'; cmd += (parent.platform == 'win32') ? ' --archive=\"nul\"' : ' --archive=\"/dev/null\"';
const child_process = require('child_process'); const child_process = require('child_process');
child_process.exec(cmd, { cwd: backupPath }, function (error, stdout, stderr) { child_process.exec(cmd, { cwd: backupPath }, function (error, stdout, stderr) {
@ -1834,7 +1834,7 @@ module.exports.CreateDB = function (parent, func) {
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; }
const child_process = require('child_process'); const child_process = require('child_process');
var cmd = '\"' + mongoDumpPath + '\" --db=\"' + dbname + '\" --archive=\"' + newBackupPath + '.archive\"'; var cmd = '\"' + mongoDumpPath + '\" --db=\"' + dbname + '\" --archive=\"' + newBackupPath + '.archive\"';
if (dburl) { cmd = '\"' + mongoDumpPath + '\" --uri=\"' + dburl.replace('?', '/?') + '\" --archive=\"' + newBackupPath + '.archive\"'; } if (dburl) { cmd = '\"' + mongoDumpPath + '\" --uri=\"' + dburl + '\" --archive=\"' + newBackupPath + '.archive\"'; }
var backupProcess = child_process.exec(cmd, { cwd: backupPath }, function (error, stdout, stderr) { var backupProcess = child_process.exec(cmd, { cwd: backupPath }, function (error, stdout, stderr) {
try { try {
var mongoDumpSuccess = true; var mongoDumpSuccess = true;