restore: carefully replace backup config
do not replace the backup policy and other flags
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user