Skip to content

Commit

Permalink
fix mysql autoback zippassword
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Smith <simonsmith5521@gmail.com>
  • Loading branch information
si458 committed Aug 15, 2024
1 parent aae551d commit c1e3354
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions db.js
Original file line number Diff line number Diff line change
Expand Up @@ -3426,13 +3426,17 @@ module.exports.CreateDB = function (parent, func) {
var archiver = require('archiver');
var output = parent.fs.createWriteStream(newAutoBackupPath + '.zip');
var archive = null;
try {
archiver.registerFormat('zip-encrypted', require('archiver-zip-encrypted'));
archive = archiver.create('zip-encrypted', { zlib: { level: 9 }, encryptionMethod: 'aes256', password: parent.config.settings.autobackup.zippassword });
if (func) { func('Creating encrypted ZIP'); }
} catch (ex) { // registering encryption failed, so create without encryption
if (parent.config.settings.autobackup && (typeof parent.config.settings.autobackup.zippassword == 'string')) {
try {
archiver.registerFormat('zip-encrypted', require('archiver-zip-encrypted'));
archive = archiver.create('zip-encrypted', { zlib: { level: 9 }, encryptionMethod: 'aes256', password: parent.config.settings.autobackup.zippassword });
if (func) { func('Creating encrypted ZIP'); }
} catch (ex) { // registering encryption failed, so create without encryption
archive = archiver('zip', { zlib: { level: 9 } });
if (func) { func('Creating encrypted ZIP failed, so falling back to normal ZIP'); }
}
} else {
archive = archiver('zip', { zlib: { level: 9 } });
if (func) { func('Creating encrypted ZIP failed, so falling back to normal ZIP'); }
}
output.on('close', function () {
obj.performingBackup = false;
Expand Down

0 comments on commit c1e3354

Please sign in to comment.