restore: carefully replace backup config

do not replace the backup policy and other flags
This commit is contained in:
Girish Ramakrishnan
2020-02-27 12:38:17 -08:00
parent cc932328ff
commit ce9834757e
3 changed files with 29 additions and 3 deletions

View File

@@ -24,6 +24,7 @@ exports = module.exports = {
getBackupConfig: getBackupConfig,
setBackupConfig: setBackupConfig,
setBackupCredentials: setBackupCredentials,
getPlatformConfig: getPlatformConfig,
setPlatformConfig: setPlatformConfig,
@@ -412,6 +413,30 @@ function setBackupConfig(backupConfig, callback) {
});
}
function setBackupCredentials(credentials, callback) {
assert.strictEqual(typeof credentials, 'object');
assert.strictEqual(typeof callback, 'function');
getBackupConfig(function (error, currentConfig) {
if (error) return callback(error);
// preserve these fields
const extra = _.pick(currentConfig, 'retentionSecs', 'intervalSecs', 'copyConcurrency', 'syncConcurrency');
const backupConfig = _.extend({}, credentials, extra);
backups.cleanupCacheFilesSync();
settingsdb.set(exports.BACKUP_CONFIG_KEY, JSON.stringify(backupConfig), function (error) {
if (error) return callback(error);
notifyChange(exports.BACKUP_CONFIG_KEY, backupConfig);
backups.configureCollectd(backupConfig, callback);
});
});
}
function getPlatformConfig(callback) {
assert.strictEqual(typeof callback, 'function');
@@ -458,10 +483,10 @@ function setExternalLdapConfig(externalLdapConfig, callback) {
assert.strictEqual(typeof externalLdapConfig, 'object');
assert.strictEqual(typeof callback, 'function');
getExternalLdapConfig(function (error, curentConfig) {
getExternalLdapConfig(function (error, currentConfig) {
if (error) return callback(error);
externalLdap.injectPrivateFields(externalLdapConfig, curentConfig);
externalLdap.injectPrivateFields(externalLdapConfig, currentConfig);
externalLdap.testConfig(externalLdapConfig, function (error) {
if (error) return callback(error);