mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-02-09 04:38:07 -05:00
Added support for auto-backup path.
This commit is contained in:
parent
51ca9088a8
commit
705be0f280
13
db.js
13
db.js
@ -679,25 +679,28 @@ module.exports.CreateDB = function (parent, func) {
|
|||||||
if (obj.performingBackup) return 1;
|
if (obj.performingBackup) return 1;
|
||||||
obj.performingBackup = true;
|
obj.performingBackup = true;
|
||||||
//console.log('Performing backup...');
|
//console.log('Performing backup...');
|
||||||
try { obj.parent.fs.mkdirSync(obj.parent.backuppath); } catch (e) { }
|
|
||||||
|
var backupPath = obj.parent.backuppath;
|
||||||
|
if (obj.parent.config.settings.autobackup && obj.parent.config.settings.autobackup.backuppath) { backupPath = obj.parent.config.settings.autobackup.backuppath; }
|
||||||
|
try { obj.parent.fs.mkdirSync(backupPath); } catch (e) { }
|
||||||
const dbname = (obj.parent.args.mongodbname) ? (obj.parent.args.mongodbname) : 'meshcentral';
|
const dbname = (obj.parent.args.mongodbname) ? (obj.parent.args.mongodbname) : 'meshcentral';
|
||||||
const currentDate = new Date();
|
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 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 newAutoBackupFile = 'meshcentral-autobackup-' + fileSuffix;
|
||||||
const newAutoBackupPath = obj.parent.path.join(obj.parent.backuppath, newAutoBackupFile);
|
const newAutoBackupPath = obj.parent.path.join(backupPath, newAutoBackupFile);
|
||||||
|
|
||||||
if ((obj.databaseType == 2) || (obj.databaseType == 3)) {
|
if ((obj.databaseType == 2) || (obj.databaseType == 3)) {
|
||||||
// Perform a MongoDump backup
|
// Perform a MongoDump backup
|
||||||
const newBackupFile = 'mongodump-' + fileSuffix;
|
const newBackupFile = 'mongodump-' + fileSuffix;
|
||||||
const newBackupPath = obj.parent.path.join(obj.parent.backuppath, newBackupFile);
|
var newBackupPath = obj.parent.path.join(backupPath, newBackupFile);
|
||||||
var mongoDumpPath = 'mongodump';
|
var mongoDumpPath = 'mongodump';
|
||||||
if (obj.parent.config.settings.autobackup && obj.parent.config.settings.autobackup.mongodumppath) { mongoDumpPath = obj.parent.config.settings.autobackup.mongodumppath; }
|
if (obj.parent.config.settings.autobackup && obj.parent.config.settings.autobackup.mongodumppath) { mongoDumpPath = obj.parent.config.settings.autobackup.mongodumppath; }
|
||||||
const child_process = require('child_process');
|
const child_process = require('child_process');
|
||||||
const cmd = mongoDumpPath + ' --db \"' + dbname + '\" --archive=\"' + newBackupPath + '.archive\"';
|
const cmd = mongoDumpPath + ' --db \"' + dbname + '\" --archive=\"' + newBackupPath + '.archive\"';
|
||||||
var backupProcess = child_process.exec(cmd, { cwd: obj.parent.backuppath }, function (error, stdout, stderr) {
|
var backupProcess = child_process.exec(cmd, { cwd: backupPath }, function (error, stdout, stderr) {
|
||||||
try {
|
try {
|
||||||
backupProcess = null;
|
backupProcess = null;
|
||||||
if ((error != null) && (error != '')) { console.log('ERROR: Unable to perform database backup.\r\n'); obj.performingBackup = false; return; }
|
if ((error != null) && (error != '')) { console.log('ERROR: Unable to perform database backup: ' + error + '\r\n'); obj.performingBackup = false; return; }
|
||||||
|
|
||||||
// Perform archive compression
|
// Perform archive compression
|
||||||
var archiver = require('archiver');
|
var archiver = require('archiver');
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "meshcentral",
|
"name": "meshcentral",
|
||||||
"version": "0.3.5-b",
|
"version": "0.3.5-c",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"Remote Management",
|
"Remote Management",
|
||||||
"Intel AMT",
|
"Intel AMT",
|
||||||
|
@ -40,7 +40,8 @@
|
|||||||
"_AutoBackup": {
|
"_AutoBackup": {
|
||||||
"backupInvervalHours": 24,
|
"backupInvervalHours": 24,
|
||||||
"keepLastDaysBackup": 10,
|
"keepLastDaysBackup": 10,
|
||||||
"zippassword": "MyReallySecretPassword3"
|
"zipPassword": "MyReallySecretPassword3",
|
||||||
|
"_backupPath": "C:\\backups"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"_domains": {
|
"_domains": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user