backups: make backup download config work

This commit is contained in:
Girish Ramakrishnan
2025-07-28 11:01:46 +02:00
parent b2c94adabf
commit 89388940ed
4 changed files with 176 additions and 108 deletions
+10 -13
View File
@@ -14,10 +14,12 @@ import AppRestoreDialog from '../AppRestoreDialog.vue';
import SettingsItem from '../SettingsItem.vue';
import AppsModel from '../../models/AppsModel.js';
import BackupsModel from '../../models/BackupsModel.js';
import BackupTargetsModel from '../../models/BackupTargetsModel.js';
import TasksModel from '../../models/TasksModel.js';
const appsModel = AppsModel.create();
const backupsModel = BackupsModel.create();
const backupTargetsModel = BackupTargetsModel.create();
const tasksModel = TasksModel.create();
const props = defineProps([ 'app' ]);
@@ -154,26 +156,21 @@ function getDownloadLink(backup) {
}
async function onDownloadConfig(backup) {
const [error, backupConfig] = await backupsModel.getConfig();
const [error, backupTarget] = await backupTargetsModel.get(backup.targetId);
if (error) return console.error(error);
// secrets and tokens already come with placeholder characters we remove them
const tmp = {
remotePath: backup.remotePath,
encrypted: !!backupConfig.password // we add this just to help the import UI
encrypted: !!backupTarget.password, // we add this just to help the import UI
encryptedFilenames: !!backupTarget.encryptedFilenames
};
Object.keys(backupConfig).forEach(k => {
const v = backupConfig[k];
if (v && typeof v === 'object') { // to hide mountOptions.password and the likes
tmp[k] = {};
Object.keys(v).forEach(function (j) {
if (v[j] !== SECRET_PLACEHOLDER) tmp[k][j] = v[j];
});
} else {
if (backupConfig[k] !== SECRET_PLACEHOLDER) tmp[k] = v;
}
});
console.log(backupTarget);
for (const k of ['provider', 'config', 'limits', 'format']) {
tmp[k] = backupTarget[k];
}
const filename = `${props.app.fqdn}-backup-config-${(new Date(backup.creationTime)).toISOString().split('T')[0]}.json`;
download(filename, JSON.stringify(tmp, null, 4));