2025-08-06 16:26:00 +02:00
|
|
|
<script setup>
|
|
|
|
|
|
2025-08-07 21:00:25 +02:00
|
|
|
import { ref, useTemplateRef } from 'vue';
|
2025-08-10 19:36:37 +02:00
|
|
|
import { Dialog, FormGroup, TextInput } from '@cloudron/pankow';
|
2025-08-06 16:26:00 +02:00
|
|
|
import { prettyBinarySize } from '@cloudron/pankow/utils';
|
|
|
|
|
import { mountlike, s3like } from '../utils.js';
|
2025-09-12 09:48:37 +02:00
|
|
|
import BackupSitesModel from '../models/BackupSitesModel.js';
|
2025-08-06 16:26:00 +02:00
|
|
|
import SystemModel from '../models/SystemModel.js';
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits([ 'success' ]);
|
|
|
|
|
|
2025-09-12 09:48:37 +02:00
|
|
|
const backupSitesModel = BackupSitesModel.create();
|
2025-08-06 16:26:00 +02:00
|
|
|
const systemModel = SystemModel.create();
|
|
|
|
|
|
2025-08-06 16:40:06 +02:00
|
|
|
const minMemoryLimit = ref(1024 * 1024 * 1024); // 1 GB
|
|
|
|
|
const maxMemoryLimit = ref(minMemoryLimit.value); // set later
|
|
|
|
|
|
2025-08-06 16:26:00 +02:00
|
|
|
const dialog = useTemplateRef('dialog');
|
2025-09-12 09:48:37 +02:00
|
|
|
const site = ref({});
|
2025-08-06 16:26:00 +02:00
|
|
|
const formError = ref({});
|
|
|
|
|
const busy = ref(false);
|
2025-08-10 19:36:37 +02:00
|
|
|
const name = ref('');
|
2025-08-06 16:40:06 +02:00
|
|
|
const memoryLimit = ref(0);
|
|
|
|
|
const uploadPartSize = ref(0);
|
|
|
|
|
const syncConcurrency = ref(0);
|
|
|
|
|
const downloadConcurrency = ref(0);
|
|
|
|
|
const copyConcurrency = ref(0);
|
2025-08-06 16:26:00 +02:00
|
|
|
|
|
|
|
|
async function onSubmit() {
|
2025-08-06 16:40:06 +02:00
|
|
|
busy.value = true;
|
|
|
|
|
|
2025-09-12 09:48:37 +02:00
|
|
|
let [error] = await backupSitesModel.setName(site.value.id, name.value);
|
2025-08-10 19:36:37 +02:00
|
|
|
if (error) {
|
|
|
|
|
formError.value.generic = error.body ? error.body.message : 'Internal error';
|
|
|
|
|
busy.value = false;
|
|
|
|
|
return console.error(error);
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-06 16:40:06 +02:00
|
|
|
const limits = {
|
|
|
|
|
memoryLimit: parseInt(memoryLimit.value),
|
|
|
|
|
uploadPartSize: parseInt(uploadPartSize.value),
|
|
|
|
|
syncConcurrency: parseInt(syncConcurrency.value),
|
|
|
|
|
downloadConcurrency: parseInt(downloadConcurrency.value),
|
|
|
|
|
copyConcurrency: parseInt(copyConcurrency.value),
|
|
|
|
|
};
|
|
|
|
|
|
2025-09-12 09:48:37 +02:00
|
|
|
[error] = await backupSitesModel.setLimits(site.value.id, limits);
|
2025-08-06 16:40:06 +02:00
|
|
|
if (error) {
|
|
|
|
|
formError.value.generic = error.body ? error.body.message : 'Internal error';
|
|
|
|
|
busy.value = false;
|
|
|
|
|
return console.error(error);
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-06 16:26:00 +02:00
|
|
|
emit('success');
|
|
|
|
|
dialog.value.close();
|
2025-08-06 16:40:06 +02:00
|
|
|
busy.value = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function getMemory() {
|
|
|
|
|
const [error, result] = await systemModel.memory();
|
|
|
|
|
if (error) return console.error(error);
|
|
|
|
|
|
|
|
|
|
maxMemoryLimit.value = Math.ceil(result.memory / (1024*1024*1024)) * 1024 * 1024 * 1024;
|
2025-08-06 16:26:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
defineExpose({
|
|
|
|
|
async open(t) {
|
|
|
|
|
formError.value = {};
|
|
|
|
|
busy.value = false;
|
2025-09-12 09:48:37 +02:00
|
|
|
site.value = t;
|
2025-08-06 16:26:00 +02:00
|
|
|
|
2025-08-10 19:36:37 +02:00
|
|
|
name.value = t.name || '';
|
2025-08-06 16:40:06 +02:00
|
|
|
memoryLimit.value = t.limits.memoryLimit || 1024 * 1024 * 1024; // 1 GB
|
|
|
|
|
uploadPartSize.value = t.limits.uploadPartSize || 10 * 1024 * 1024;
|
|
|
|
|
syncConcurrency.value = t.limits.syncConcurrency || 10;
|
|
|
|
|
downloadConcurrency.value = t.limits.downloadConcurrency || 10;
|
|
|
|
|
copyConcurrency.value = t.limits.copyConcurrency || 10;
|
|
|
|
|
|
|
|
|
|
await getMemory();
|
2025-08-06 16:26:00 +02:00
|
|
|
|
|
|
|
|
dialog.value.open();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<Dialog ref="dialog"
|
|
|
|
|
:title="$t('backups.configureBackupStorage.title')"
|
|
|
|
|
:reject-label="$t('main.dialog.close')"
|
2025-09-23 12:15:27 +02:00
|
|
|
:reject-active="!busy"
|
2025-08-06 16:26:00 +02:00
|
|
|
reject-style="secondary"
|
|
|
|
|
:confirm-label="$t('main.dialog.save')"
|
2025-09-23 12:15:27 +02:00
|
|
|
:confirm-busy="busy"
|
2025-08-06 16:26:00 +02:00
|
|
|
confirm-style="primary"
|
|
|
|
|
@confirm="onSubmit()"
|
|
|
|
|
>
|
|
|
|
|
<div>
|
|
|
|
|
<div>
|
|
|
|
|
<div class="info-row">
|
|
|
|
|
<div class="info-label">{{ $t('backups.configureBackupStorage.provider') }}</div>
|
2025-09-12 09:48:37 +02:00
|
|
|
<div class="info-value">{{ site.provider }}</div>
|
2025-08-06 16:26:00 +02:00
|
|
|
</div>
|
2025-09-12 09:48:37 +02:00
|
|
|
<div class="info-row" v-if="site.provider !== 'noop'">
|
2025-08-06 16:26:00 +02:00
|
|
|
<div class="info-label">{{ $t('backups.configureBackupStorage.format') }}</div>
|
2025-09-12 09:48:37 +02:00
|
|
|
<div class="info-value">{{ site.format }} <i v-if="site.encrypted" class="fa-solid fa-lock"></i></div>
|
2025-08-06 16:26:00 +02:00
|
|
|
</div>
|
2025-09-12 09:48:37 +02:00
|
|
|
<div class="info-row" v-if="site.provider !== 'noop'">
|
2025-08-06 16:26:00 +02:00
|
|
|
<div class="info-label">{{ $t('backups.location.location') }}</div>
|
2025-08-13 16:54:38 +02:00
|
|
|
<div class="info-value" style="overflow: auto;">
|
2025-09-12 09:48:37 +02:00
|
|
|
<span v-if="mountlike(site.provider) || site.provider === 'filesystem'">
|
|
|
|
|
<span v-if="site.provider === 'filesystem'">{{ site.config.backupDir }}{{ (site.config.prefix ? `/${site.config.prefix}` : '') }}</span>
|
2025-09-23 18:54:20 +02:00
|
|
|
<span v-if="site.provider === 'disk' || site.provider === 'ext4' || site.provider === 'xfs' || site.provider === 'mountpoint'">{{ site.config.mountOptions.diskPath || site.config.mountPoint }}{{ (site.config.prefix ? `/${site.config.prefix}` : '') }}</span>
|
|
|
|
|
<span v-if="site.provider === 'cifs' || site.provider === 'nfs' || site.provider === 'sshfs'">{{ site.config.mountOptions.host }}:{{ site.config.mountOptions.remoteDir }}{{ (site.config.prefix ? `/${site.config.prefix}` : '') }}</span>
|
2025-08-06 16:26:00 +02:00
|
|
|
</span>
|
|
|
|
|
|
2025-09-23 18:54:20 +02:00
|
|
|
<span v-if="site.provider !== 's3' && site.provider !== 'minio' && (s3like(site.provider) || site.provider === 'gcs')">{{ site.config.bucket + (site.config.prefix ? `/${site.config.prefix}` : '') }}</span>
|
|
|
|
|
<span v-if="site.provider === 's3'">{{ site.config.region + ' ' + site.config.bucket + (site.config.prefix ? `/${site.config.prefix}` : '') }}</span>
|
|
|
|
|
<span v-if="site.provider === 'minio'">{{ site.config.endpoint + ' ' + site.config.bucket + (site.config.prefix ? `/${site.config.prefix}` : '') }}</span>
|
2025-08-06 16:26:00 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-09-12 09:48:37 +02:00
|
|
|
<div class="info-row" v-if="site.provider !== 'minio' && site.config?.endpoint">
|
2025-08-06 16:26:00 +02:00
|
|
|
<div class="info-label">{{ $t('backups.location.endpoint') }}</div>
|
2025-09-12 09:48:37 +02:00
|
|
|
<div class="info-value">{{ site.config.endpoint || site.config.region }}</div>
|
2025-08-06 16:26:00 +02:00
|
|
|
</div>
|
2025-09-12 09:48:37 +02:00
|
|
|
<div class="info-row" v-if="site.encrypted">
|
2025-08-10 19:36:37 +02:00
|
|
|
<div class="info-label">{{ $t('backups.configureBackupStorage.encryptionHint') }}</div>
|
2025-09-12 09:48:37 +02:00
|
|
|
<div class="info-value">{{ site.encryptionPasswordHint }}</div>
|
2025-08-06 16:26:00 +02:00
|
|
|
</div>
|
2025-08-06 16:40:06 +02:00
|
|
|
|
2025-08-10 19:36:37 +02:00
|
|
|
<form @submit.prevent="onSubmit()" autocomplete="off" ref="form">
|
|
|
|
|
<fieldset :disabled="busy">
|
|
|
|
|
<input style="display: none;" type="submit"/>
|
|
|
|
|
|
|
|
|
|
<FormGroup>
|
|
|
|
|
<label for="nameInput">{{ $t('backups.configureBackupStorage.name') }}</label>
|
|
|
|
|
<TextInput id="nameInput" v-model="name" required/>
|
|
|
|
|
</FormGroup>
|
|
|
|
|
|
|
|
|
|
<FormGroup>
|
|
|
|
|
<label for="memoryLimitInput">{{ $t('backups.configureBackupStorage.memoryLimit') }}: <b>{{ prettyBinarySize(memoryLimit, '1024 MB') }}</b></label>
|
|
|
|
|
<div class="small">{{ $t('backups.configureBackupStorage.memoryLimitDescription') }}</div>
|
|
|
|
|
<input type="range" id="memoryLimitInput" v-model="memoryLimit" :step="256*1024*1024" :min="minMemoryLimit" :max="maxMemoryLimit" />
|
|
|
|
|
</FormGroup>
|
|
|
|
|
|
|
|
|
|
<FormGroup>
|
|
|
|
|
<label for="memoryLimitInput">{{ $t('backups.configureBackupStorage.memoryLimit') }}: <b>{{ prettyBinarySize(memoryLimit, '1024 MB') }}</b></label>
|
|
|
|
|
<div class="small">{{ $t('backups.configureBackupStorage.memoryLimitDescription') }}</div>
|
|
|
|
|
<input type="range" id="memoryLimitInput" v-model="memoryLimit" :step="256*1024*1024" :min="minMemoryLimit" :max="maxMemoryLimit" />
|
|
|
|
|
</FormGroup>
|
|
|
|
|
|
2025-09-12 09:48:37 +02:00
|
|
|
<FormGroup v-if="s3like(site.provider)">
|
2025-08-10 19:36:37 +02:00
|
|
|
<label for="uploadPartSizeInput">{{ $t('backups.configureBackupStorage.uploadPartSize') }}: <b>{{ prettyBinarySize(uploadPartSize, 'Default (50 MiB)') }}</b></label>
|
|
|
|
|
<p class="small">{{ $t('backups.configureBackupStorage.uploadPartSizeDescription') }}</p>
|
|
|
|
|
<input type="range" id="uploadPartSizeInput" v-model="uploadPartSize" list="uploadPartSizeTicks" :step="1024*1024" :min="10*1024*1024" :max="1024*1024*1024" />
|
|
|
|
|
<datalist id="uploadPartSizeTicks">
|
|
|
|
|
<option :value="1024*1024*10"></option>
|
|
|
|
|
<option :value="1024*1024*64"></option>
|
|
|
|
|
<option :value="1024*1024*128"></option>
|
|
|
|
|
<option :value="1024*1024*256"></option>
|
|
|
|
|
<option :value="1024*1024*512"></option>
|
|
|
|
|
<option :value="1024*1024*1024"></option>
|
|
|
|
|
</datalist>
|
|
|
|
|
</FormGroup>
|
|
|
|
|
|
2025-09-12 09:48:37 +02:00
|
|
|
<FormGroup v-if="site.format === 'rsync' && site.provider !== 'noop'">
|
2025-08-10 19:36:37 +02:00
|
|
|
<label for="syncConcurrencyInput">{{ $t('backups.configureBackupStorage.uploadConcurrency') }}: <b>{{ syncConcurrency }}</b></label>
|
|
|
|
|
<div class="small">{{ $t('backups.configureBackupStorage.uploadConcurrencyDescription') }}</div>
|
|
|
|
|
<input type="range" id="syncConcurrencyInput" v-model="syncConcurrency" step="10" min="10" max="200" />
|
|
|
|
|
</FormGroup>
|
|
|
|
|
|
2025-09-12 09:48:37 +02:00
|
|
|
<FormGroup v-if="site.format === 'rsync' && (s3like(site.provider) || site.provider === 'gcs')">
|
2025-08-10 19:36:37 +02:00
|
|
|
<label for="downloadConcurrencyInput">{{ $t('backups.configureBackupStorage.downloadConcurrency') }}: <b>{{ downloadConcurrency }}</b></label>
|
|
|
|
|
<div class="small">{{ $t('backups.configureBackupStorage.downloadConcurrencyDescription') }}</div>
|
|
|
|
|
<input type="range" id="downloadConcurrencyInput" v-model="downloadConcurrency" step="10" min="10" max="200" />
|
|
|
|
|
</FormGroup>
|
|
|
|
|
|
2025-09-12 09:48:37 +02:00
|
|
|
<FormGroup v-if="site.format === 'rsync' && (s3like(site.provider) || site.provider === 'gcs')">
|
2025-08-10 19:36:37 +02:00
|
|
|
<label for="copyConcurrencyInput">{{ $t('backups.configureBackupStorage.copyConcurrency') }}: <b>{{ copyConcurrency }}</b></label>
|
|
|
|
|
<div class="small">{{ $t('backups.configureBackupStorage.copyConcurrencyDescription') }}
|
2025-09-12 09:48:37 +02:00
|
|
|
<span v-show="site.provider === 'digitalocean-spaces'">{{ $t('backups.configureBackupStorage.copyConcurrencyDigitalOceanNote') }}</span>
|
2025-08-10 19:36:37 +02:00
|
|
|
</div>
|
|
|
|
|
<input type="range" id="copyConcurrencyInput" v-model="copyConcurrency" step="10" min="10" max="500" />
|
|
|
|
|
</FormGroup>
|
|
|
|
|
</fieldset>
|
|
|
|
|
</form>
|
2025-08-06 16:26:00 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</Dialog>
|
|
|
|
|
</template>
|