Add mongodump args option (#6921)

* Add mongodump args option

* Put mongodumpargs in proper place
This commit is contained in:
PTR 2025-04-12 11:00:32 +02:00 committed by GitHub
parent 42d02fdb84
commit c202339b67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

7
db.js
View File

@ -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;}
});

View File

@ -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=<mongoDb>. 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",