Make backupSite contents configurable

This commit is contained in:
Johannes Zellner
2025-09-24 18:11:48 +02:00
parent 0dfd8b9f53
commit c8c5862b47
3 changed files with 106 additions and 3 deletions

View File

@@ -1,16 +1,18 @@
<script setup>
import { ref, useTemplateRef, watch } from 'vue';
import { Dialog, FormGroup, TextInput, PasswordInput, Button, Checkbox } from '@cloudron/pankow';
import { Dialog, Radiobutton, MultiSelect, FormGroup, TextInput, PasswordInput, Button, Checkbox } from '@cloudron/pankow';
import { prettyBinarySize } from '@cloudron/pankow/utils';
import { REGIONS_CONTABO, REGIONS_VULTR, REGIONS_IONOS, REGIONS_OVH, REGIONS_LINODE, REGIONS_SCALEWAY, REGIONS_WASABI } from '../constants.js';
import { mountlike, s3like } from '../utils.js';
import BackupProviderForm from './BackupProviderForm.vue';
import AppsModel from '../models/AppsModel.js';
import BackupSitesModel from '../models/BackupSitesModel.js';
import SystemModel from '../models/SystemModel.js';
const emit = defineEmits([ 'success' ]);
const appsModel = AppsModel.create();
const backupSitesModel = BackupSitesModel.create();
const systemModel = SystemModel.create();
@@ -28,6 +30,10 @@ const formError = ref({});
const busy = ref(false);
const enableForUpdates = ref(false);
const provider = ref('');
const includeExclude = ref('include'); // or exclude
const contentOptions = ref([]);
const contentInclude = ref([]);
const contentExclude = ref([]);
const providerConfig = ref({
mountOptions: {},
prefix: '',
@@ -150,7 +156,14 @@ async function onSubmit() {
busy.value = true;
// everything
const contents = null;
let contents;
if (includeExclude.value === 'exclude') {
contents = { exclude: contentExclude.value };
} else if (includeExclude.value === 'include' && contentInclude.value.length) {
contents = { include: contentInclude.value };
} else {
contents = null;
}
const [error, result] = await backupSitesModel.add(name.value, format.value, contents, enableForUpdates.value, provider.value, data, schedulePattern, retention, limitsConfig);
if (error) {
@@ -232,6 +245,9 @@ defineExpose({
encryptionPasswordHint.value = '';
encryptedFilenames.value = false;
limits.value = {};
includeExclude.value = 'include';
contentInclude.value = [];
contentExclude.value = [];
// some sane defaults
limits.value.memoryLimit = 1024 * 1024 * 1024; // 1 GB
@@ -248,6 +264,21 @@ defineExpose({
await getMemory();
const [error, result] = await appsModel.list();
if (error) return console.error(error);
contentOptions.value = [{
id: 'box',
label: 'Platform',
}];
result.forEach(a => {
contentOptions.value.push({
id: a.id,
label: `${a.label || a.fqdn} - ${a.manifest.title}`,
});
});
dialog.value.open();
}
});
@@ -267,6 +298,14 @@ defineExpose({
<TextInput id="nameInput" v-model="name" required/>
</FormGroup>
<FormGroup>
<label>Contents</label>
<Radiobutton v-model="includeExclude" value="include" label="Include everything, exclude optionally the following:"/>
<MultiSelect v-model="contentInclude" v-if="includeExclude === 'include'" :options="contentOptions" :search-threshold="10" option-key="id"/>
<Radiobutton v-model="includeExclude" value="exclude" label="Only the following:"/>
<MultiSelect v-model="contentExclude" v-if="includeExclude === 'exclude'" :options="contentOptions" :search-threshold="10" option-key="id"/>
</FormGroup>
<Checkbox v-model="enableForUpdates" :label="$t('backups.configureBackupStorage.useForUpdates')" />
<BackupProviderForm v-model:provider="provider" v-model:format="format" v-model:provider-config="providerConfig" :form-error="formError"/>