Added mysql/mariadb to getBackupConfig

Noah Zalev committed Apr 24, 2021 at 19:51 UTC f0751bab397088be9ff1befda4ca4180f7144c0a
1 file changed +11 -2
db.js
+11 -2
@@ -1529,14 +1529,19 @@ module.exports.CreateDB = function (parent, func) {
1529 obj.getBackupConfig = function () {
1530 var r = '', backupPath = parent.backuppath;
1531 if (parent.config.settings.autobackup && parent.config.settings.autobackup.backuppath) { backupPath = parent.config.settings.autobackup.backuppath; }
1532 - const dbname = (parent.args.mongodbname) ? (parent.args.mongodbname) : 'meshcentral';
1532 +
1533 + var dbname = 'meshcentral';
1534 + if (parent.args.mongodbname) { dbname = parent.args.mongodbname; }
1535 + else if (parent.args.mariadb.database) { dbname = parent.args.mariadb.database; }
1536 + else if (parent.args.mysql.database) { dbname = parent.args.mysql.database; }
1537 +
1538 const currentDate = new Date();
1539 const fileSuffix = currentDate.getFullYear() + '-' + padNumber(currentDate.getMonth() + 1, 2) + '-' + padNumber(currentDate.getDate(), 2) + '-' + padNumber(currentDate.getHours(), 2) + '-' + padNumber(currentDate.getMinutes(), 2);
1540 const newAutoBackupFile = 'meshcentral-autobackup-' + fileSuffix;
1541 const newAutoBackupPath = parent.path.join(backupPath, newAutoBackupFile);
1542
1543 r += 'DB Name: ' + dbname + '\r\n';
1539 - r += 'DB Type: ' + ['None', 'NeDB', 'MongoJS', 'MongoDB'][obj.databaseType] + '\r\n';
1544 + r += 'DB Type: ' + ['None', 'NeDB', 'MongoJS', 'MongoDB', 'MariaDB', 'MySQL'][obj.databaseType] + '\r\n';
1545 r += 'BackupPath: ' + backupPath + '\r\n';
1546 r += 'newAutoBackupFile: ' + newAutoBackupFile + '\r\n';
1547 r += 'newAutoBackupPath: ' + newAutoBackupPath + '\r\n';
@@ -1560,6 +1565,10 @@ module.exports.CreateDB = function (parent, func) {
1565 if (typeof parent.config.settings.autobackup.mongodumppath != 'string') { r += 'Bad mongodumppath type\r\n'; }
1566 else { r += 'MongoDump Path: ' + parent.config.settings.autobackup.mongodumppath + '\r\n'; }
1567 }
1568 + if (parent.config.settings.autobackup.mysqldumppath != null) {
1569 + if (typeof parent.config.settings.autobackup.mysqldumppath != 'string') { r += 'Bad mysqldump type\r\n'; }
1570 + else { r += 'MySqlDump Path: ' + parent.config.settings.autobackup.mysqldumppath + '\r\n'; }
1571 + }
1572 }
1573
1574 return r;