From c202339b67cb579f942cd2d8fa50f586fff4468a Mon Sep 17 00:00:00 2001 From: PTR <47147771+PTR-inc@users.noreply.github.com> Date: Sat, 12 Apr 2025 11:00:32 +0200 Subject: [PATCH] Add mongodump args option (#6921) * Add mongodump args option * Put mongodumpargs in proper place --- db.js | 7 +++++-- meshcentral-config-schema.json | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/db.js b/db.js index 79387758..39309c94 100644 --- a/db.js +++ b/db.js @@ -3323,7 +3323,10 @@ module.exports.CreateDB = function (parent, func) { var cmd = '"' + mongoDumpPath + '"'; if (dburl) { cmd = '\"' + mongoDumpPath + '\" --uri=\"' + dburl + '\"'; } - + if (parent.config.settings.autobackup?.mongodumpargs) { + cmd = '\"' + mongoDumpPath + '\" ' + parent.config.settings.autobackup.mongodumpargs; + if (!parent.config.settings.autobackup.mongodumpargs.includes("--db=")) {cmd += ' --db=' + (parent.config.settings.mongodbname ? parent.config.settings.mongodbname : 'meshcentral')}; + } return cmd; } @@ -3378,7 +3381,7 @@ module.exports.CreateDB = function (parent, func) { const child_process = require('child_process'); child_process.exec(cmd, { cwd: backupPath }, function (error, stdout, stderr) { if ((error != null) && (error != '')) { - func(1, "Unable to find mongodump tool, backup will not be performed. Command tried: " + cmd); + func(1, "Mongodump error, backup will not be performed. Command tried: " + cmd + ' --> ERROR: ' + stderr); return; } else {parent.config.settings.autobackup.backupintervalhours = backupInterval;} }); diff --git a/meshcentral-config-schema.json b/meshcentral-config-schema.json index f53bccbb..9e7daffd 100644 --- a/meshcentral-config-schema.json +++ b/meshcentral-config-schema.json @@ -886,6 +886,10 @@ "default": "mongodump", "description": "The file path of where \"mongodump\" is located. Default is \"mongodump\"" }, + "mongoDumpArgs": { + "type": "string", + "description": "Override the default mongodump --uri=. The --db= option is automatically appended if omitted. (f.e. --host=127.0.0.1 --username=someUser --password=PaSsWORD --authenticationDatabase=admin)" + }, "mysqlDumpPath": { "type": "string", "default": "mysqldump",