mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-26 23:25:53 -05:00
One more fix for mongodump.exe invocation.
This commit is contained in:
parent
c62362a7f7
commit
626364bab8
10
db.js
10
db.js
@ -1644,6 +1644,12 @@ module.exports.CreateDB = function (parent, func) {
|
|||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MongoDB mongodump requires that the URL have a / at the end of the path. If not present, this will add it.
|
||||||
|
function terminateUrlPathWithSlash(str) {
|
||||||
|
const u = require('url').parse(str);
|
||||||
|
return u.protocol + '//' + u.host + (u.pathname ? u.pathname : '') + '/' + (u.search ? u.search : '');
|
||||||
|
}
|
||||||
|
|
||||||
// Check that the server is capable of performing a backup
|
// Check that the server is capable of performing a backup
|
||||||
obj.checkBackupCapability = function (func) {
|
obj.checkBackupCapability = function (func) {
|
||||||
if ((parent.config.settings.autobackup == null) || (parent.config.settings.autobackup == false)) { func(); }
|
if ((parent.config.settings.autobackup == null) || (parent.config.settings.autobackup == false)) { func(); }
|
||||||
@ -1656,7 +1662,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 + '\"'; }
|
if (dburl) { cmd = '\"' + mongoDumpPath + '\" --uri=\"' + terminateUrlPathWithSlash(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 +1840,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 + '\" --archive=\"' + newBackupPath + '.archive\"'; }
|
if (dburl) { cmd = '\"' + mongoDumpPath + '\" --uri=\"' + terminateUrlPathWithSlash(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;
|
||||||
|
Loading…
Reference in New Issue
Block a user