Added backupconfig command in server console.

This commit is contained in:
Ylian Saint-Hilaire 2019-06-07 16:44:00 -07:00
parent c177c25b34
commit 85ed10abd8
5 changed files with 54 additions and 6 deletions

40
db.js
View File

@ -706,6 +706,46 @@ module.exports.CreateDB = function (parent, func) {
func(obj); // Completed function setup func(obj); // Completed function setup
} }
// Return a human readable string with current backup configuration
obj.getBackupConfig = function () {
var r = '', backupPath = parent.backuppath;
if (parent.config.settings.autobackup && parent.config.settings.autobackup.backuppath) { backupPath = parent.config.settings.autobackup.backuppath; }
const dbname = (parent.args.mongodbname) ? (parent.args.mongodbname) : 'meshcentral';
const currentDate = new Date();
const fileSuffix = currentDate.getFullYear() + '-' + padNumber(currentDate.getMonth() + 1, 2) + '-' + padNumber(currentDate.getDate(), 2) + '-' + padNumber(currentDate.getHours(), 2) + '-' + padNumber(currentDate.getMinutes(), 2);
const newAutoBackupFile = 'meshcentral-autobackup-' + fileSuffix;
const newAutoBackupPath = parent.path.join(backupPath, newAutoBackupFile);
r += 'DB Name: ' + dbname + '\r\n';
r += 'DB Type: ' + ['None','NeDB','MongoJS','MongoDB'][obj.databaseType] + '\r\n';
r += 'BackupPath: ' + backupPath + '\r\n';
r += 'newAutoBackupFile: ' + newAutoBackupFile + '\r\n';
r += 'newAutoBackupPath: ' + newAutoBackupPath + '\r\n';
if (parent.config.settings.autobackup == null) {
r += 'No Settings/AutoBackup\r\n';
} else {
if (parent.config.settings.autobackup.backupintervalhours != null) {
if (typeof parent.config.settings.autobackup.backupintervalhours != 'number') { r += 'Bad backupintervalhours type\r\n'; }
else { r += 'Backup Interval (Hours): ' + parent.config.settings.autobackup.backupintervalhours + '\r\n'; }
}
if (parent.config.settings.autobackup.keeplastdaysbackup != null) {
if (typeof parent.config.settings.autobackup.keeplastdaysbackup != 'number') { r += 'Bad keeplastdaysbackup type\r\n'; }
else { r += 'Keep Last Backups (Days): ' + parent.config.settings.autobackup.keeplastdaysbackup + '\r\n'; }
}
if (parent.config.settings.autobackup.zippassword != null) {
if (typeof parent.config.settings.autobackup.zippassword != 'string') { r += 'Bad zippassword type\r\n'; }
else { r += 'ZIP Password Set\r\n'; }
}
if (parent.config.settings.autobackup.mongodumppath != null) {
if (typeof parent.config.settings.autobackup.mongodumppath != 'string') { r += 'Bad mongodumppath type\r\n'; }
else { r += 'MongoDump Path: ' + parent.config.settings.autobackup.mongodumppath + '\r\n'; }
}
}
return r;
}
obj.performingBackup = false; obj.performingBackup = false;
obj.performBackup = function () { obj.performBackup = function () {
try { try {

View File

@ -546,7 +546,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
case 'help': { case 'help': {
r = 'Available commands: help, info, versions, args, resetserver, showconfig, usersessions, tasklimiter, setmaxtasks, cores,\r\n' r = 'Available commands: help, info, versions, args, resetserver, showconfig, usersessions, tasklimiter, setmaxtasks, cores,\r\n'
r += 'migrationagents, agentstats, webstats, mpsstats, swarmstats, acceleratorsstats, updatecheck, serverupdate, nodeconfig,\r\n'; r += 'migrationagents, agentstats, webstats, mpsstats, swarmstats, acceleratorsstats, updatecheck, serverupdate, nodeconfig,\r\n';
r += 'heapdump, relays, autobackup, dupagents.'; r += 'heapdump, relays, autobackup, backupconfig, dupagents.';
break; break;
} }
case 'dupagents': { case 'dupagents': {
@ -737,6 +737,10 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
if (backupResult == 0) { r = 'Starting auto-backup...'; } else { r = 'Backup alreay in progress.'; } if (backupResult == 0) { r = 'Starting auto-backup...'; } else { r = 'Backup alreay in progress.'; }
break; break;
} }
case 'backupconfig': {
r = parent.db.getBackupConfig();
break;
}
default: { // This is an unknown command, return an error message default: { // This is an unknown command, return an error message
r = 'Unknown command \"' + cmd + '\", type \"help\" for list of avaialble commands.'; r = 'Unknown command \"' + cmd + '\", type \"help\" for list of avaialble commands.';
break; break;

View File

@ -1,6 +1,6 @@
{ {
"name": "meshcentral", "name": "meshcentral",
"version": "0.3.6-g", "version": "0.3.6-h",
"keywords": [ "keywords": [
"Remote Management", "Remote Management",
"Intel AMT", "Intel AMT",

View File

@ -81,6 +81,9 @@
"_MaxAgentSessions": 100, "_MaxAgentSessions": 100,
"MaxSingleUserSessions": 10 "MaxSingleUserSessions": 10
}, },
"_Redirects": {
"meshcommander": "https://www.meshcommander.com/"
},
"_yubikey": { "id": "0000", "secret": "xxxxxxxxxxxxxxxxxxxxx", "_proxy": "http://myproxy.domain.com:80" }, "_yubikey": { "id": "0000", "secret": "xxxxxxxxxxxxxxxxxxxxx", "_proxy": "http://myproxy.domain.com:80" },
"_httpheaders": { "Strict-Transport-Security": "max-age=360000" }, "_httpheaders": { "Strict-Transport-Security": "max-age=360000" },
"_agentConfig": [ "webSocketMaskOverride=1" ] "_agentConfig": [ "webSocketMaskOverride=1" ]

View File

@ -40,6 +40,7 @@
border: 1px solid #ccc; border: 1px solid #ccc;
border-top: none; border-top: none;
} }
</style> </style>
</head> </head>
<body id="body" onload="if (typeof(startup) !== 'undefined') startup();" style="display:none;overflow:hidden"> <body id="body" onload="if (typeof(startup) !== 'undefined') startup();" style="display:none;overflow:hidden">
@ -69,7 +70,7 @@
</div> </div>
</div> </div>
<div id="column_l" style="max-height:calc(100vh - 135px);overflow-y:auto"> <div id="column_l" style="max-height:calc(100vh - 135px);overflow-y:auto">
<h1>Agent Installation<span id="groupname"></span></h1> <h1>Remote Agent Installation<span id="groupname"></span></h1>
<p> <p>
You have been invited to install a software that will allow a remote operator to fully access your computer remotely including the desktop and files. You have been invited to install a software that will allow a remote operator to fully access your computer remotely including the desktop and files.
Only follow the instructions below if this invitation was expected and you know who will be accessing your computer. Only follow the instructions below if this invitation was expected and you know who will be accessing your computer.
@ -87,7 +88,7 @@
<h3>Microsoft&trade; Windows 64bit</h3> <h3>Microsoft&trade; Windows 64bit</h3>
<p><a id="win64url">Download the software here</a>, run it and press "Install" or "Connect".</p> <p><a id="win64url">Download the software here</a>, run it and press "Install" or "Connect".</p>
<div style="text-align:center"> <div style="text-align:center">
<img src="images/winagent.png" /> <img class="winagent-img" src="images/winagent.png" />
</div> </div>
</div> </div>
@ -95,7 +96,7 @@
<h3>Microsoft&trade; Windows 32bit</h3> <h3>Microsoft&trade; Windows 32bit</h3>
<p><a id="win32url">Download the software here</a>, run it and press "Install" or "Connect".</p> <p><a id="win32url">Download the software here</a>, run it and press "Install" or "Connect".</p>
<div style="text-align:center"> <div style="text-align:center">
<img src="images/winagent.png" /> <img class="winagent-img" src="images/winagent.png" />
</div> </div>
</div> </div>
@ -142,7 +143,7 @@
var serverNoProxy = "{{{servernoproxy}}}"; var serverNoProxy = "{{{servernoproxy}}}";
var installFlags = "{{{installflags}}}"; var installFlags = "{{{installflags}}}";
var groupName = decodeURIComponent("{{{meshname}}}"); var groupName = decodeURIComponent("{{{meshname}}}");
if (groupName != '') { QH('groupname', ' - ' + groupName); } if (groupName != '') { QH('groupname', ' for ' + groupName); }
userInterfaceSelectMenu(); userInterfaceSelectMenu();
setup(); setup();