mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-11-27 02:04:30 +03:00
Fix for #2666
This commit is contained in:
parent
87d6179e35
commit
76fde352f6
13
db.js
13
db.js
@ -1644,12 +1644,6 @@ 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(); }
|
||||||
@ -1662,12 +1656,15 @@ 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=\"' + terminateUrlPathWithSlash(dburl) + '\"'; }
|
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) {
|
||||||
try {
|
try {
|
||||||
if ((error != null) && (error != '')) {
|
if ((error != null) && (error != '')) {
|
||||||
|
|
||||||
|
console.log(error);
|
||||||
|
|
||||||
if (parent.platform == 'win32') {
|
if (parent.platform == 'win32') {
|
||||||
func(1, "Unable to find mongodump.exe, MongoDB database auto-backup will not be performed.");
|
func(1, "Unable to find mongodump.exe, MongoDB database auto-backup will not be performed.");
|
||||||
} else {
|
} else {
|
||||||
@ -1840,7 +1837,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=\"' + terminateUrlPathWithSlash(dburl) + '\" --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;
|
||||||
|
@ -9,8 +9,8 @@ if (!String.prototype.startsWith) { String.prototype.startsWith = function (str)
|
|||||||
if (!String.prototype.endsWith) { String.prototype.endsWith = function (str) { return this.indexOf(str, this.length - str.length) !== -1; }; }
|
if (!String.prototype.endsWith) { String.prototype.endsWith = function (str) { return this.indexOf(str, this.length - str.length) !== -1; }; }
|
||||||
|
|
||||||
// Quick UI functions, a bit of a replacement for jQuery
|
// Quick UI functions, a bit of a replacement for jQuery
|
||||||
function Q(x) { if (document.getElementById(x) == null) { console.log('Invalid element: ' + x); } return document.getElementById(x); } // "Q"
|
//function Q(x) { if (document.getElementById(x) == null) { console.log('Invalid element: ' + x); } return document.getElementById(x); } // "Q"
|
||||||
//function Q(x) { return document.getElementById(x); } // "Q"
|
function Q(x) { return document.getElementById(x); } // "Q"
|
||||||
function QS(x) { try { return Q(x).style; } catch (x) { } } // "Q" style
|
function QS(x) { try { return Q(x).style; } catch (x) { } } // "Q" style
|
||||||
function QE(x, y) { try { Q(x).disabled = !y; } catch (x) { } } // "Q" enable
|
function QE(x, y) { try { Q(x).disabled = !y; } catch (x) { } } // "Q" enable
|
||||||
function QV(x, y) { try { QS(x).display = (y ? '' : 'none'); } catch (x) { } } // "Q" visible
|
function QV(x, y) { try { QS(x).display = (y ? '' : 'none'); } catch (x) { } } // "Q" visible
|
||||||
|
Loading…
Reference in New Issue
Block a user