diff --git a/dashboard/src/components/BackupScheduleDialog.vue b/dashboard/src/components/BackupScheduleDialog.vue
index e08242435..54e31d02f 100644
--- a/dashboard/src/components/BackupScheduleDialog.vue
+++ b/dashboard/src/components/BackupScheduleDialog.vue
@@ -8,31 +8,6 @@ const emit = defineEmits([ 'success' ]);
const backupSitesModel = BackupSitesModel.create();
-const backupRetentions = [
- { name: '2 days', id: { keepWithinSecs: 2 * 24 * 60 * 60 }},
- { name: '1 week', id: { keepWithinSecs: 7 * 24 * 60 * 60 }}, // default
- { name: '1 month', id: { keepWithinSecs: 30 * 24 * 60 * 60 }},
- { name: '3 months', id: { keepWithinSecs: 3 * 30 * 24 * 60 * 60 }},
- { name: '2 daily, 4 weekly', id: { keepDaily: 2, keepWeekly: 4 }},
- { name: '3 daily, 4 weekly, 6 monthly', id: { keepDaily: 3, keepWeekly: 4, keepMonthly: 6 }},
- { name: '7 daily, 4 weekly, 12 monthly', id: { keepDaily: 7, keepWeekly: 4, keepMonthly: 12 }},
- { name: 'Forever', id: { keepWithinSecs: -1 }}
-];
-
-// values correspond to cron days
-const cronDays = [
- { id: 0, name: 'Sunday' },
- { id: 1, name: 'Monday' },
- { id: 2, name: 'Tuesday' },
- { id: 3, name: 'Wednesday' },
- { id: 4, name: 'Thursday' },
- { id: 5, name: 'Friday' },
- { id: 6, name: 'Saturday' },
-];
-
-// generates 24h time sets (instead of american 12h) to avoid having to translate everything to locales eg. 12:00
-const cronHours = Array.from({ length: 24 }).map(function (v, i) { return { id: i, name: (i < 10 ? '0' : '') + i + ':00' }; });
-
const id = ref('');
const busy = ref(false);
const formError = ref('');
@@ -92,8 +67,8 @@ defineExpose({
formError.value = false;
const currentRetentionString = JSON.stringify(site.retention);
- let selectedRetention = backupRetentions.find(function (x) { return JSON.stringify(x.id) === currentRetentionString; });
- if (!selectedRetention) selectedRetention = backupRetentions[0];
+ let selectedRetention = BackupSitesModel.backupRetentions.find(function (x) { return JSON.stringify(x.id) === currentRetentionString; });
+ if (!selectedRetention) selectedRetention = BackupSitesModel.backupRetentions[0];
configureRetention.value = selectedRetention.id;
if (site.schedule === 'never') {
@@ -105,10 +80,10 @@ defineExpose({
const tmpHours = tmp[2].split(',');
const tmpDays = tmp[5].split(',');
- if (tmpDays[0] === '*') days.value = cronDays.map((day) => { return day.id; });
+ if (tmpDays[0] === '*') days.value = BackupSitesModel.cronDays.map((day) => { return day.id; });
else days.value = tmpDays.map((day) => { return parseInt(day, 10); });
- if (tmpHours[0] === '*') hours.value = cronHours.map(h => h.id);
+ if (tmpHours[0] === '*') hours.value = BackupSitesModel.cronHours.map(h => h.id);
else hours.value = tmpHours.map((hour) => { return parseInt(hour, 10); });
}
@@ -139,15 +114,15 @@ defineExpose({
-
{{ $t('backups.configureBackupSchedule.days') }}:
-
{{ $t('backups.configureBackupSchedule.hours') }}:
+
{{ $t('backups.configureBackupSchedule.days') }}:
+
{{ $t('backups.configureBackupSchedule.hours') }}:
diff --git a/dashboard/src/models/BackupSitesModel.js b/dashboard/src/models/BackupSitesModel.js
index 9dd5251a9..94f6914f6 100644
--- a/dashboard/src/models/BackupSitesModel.js
+++ b/dashboard/src/models/BackupSitesModel.js
@@ -193,6 +193,57 @@ function create() {
};
}
+const backupRetentions = [
+ { name: '2 days', id: { keepWithinSecs: 2 * 24 * 60 * 60 }},
+ { name: '1 week', id: { keepWithinSecs: 7 * 24 * 60 * 60 }}, // default
+ { name: '1 month', id: { keepWithinSecs: 30 * 24 * 60 * 60 }},
+ { name: '3 months', id: { keepWithinSecs: 3 * 30 * 24 * 60 * 60 }},
+ { name: '2 daily, 4 weekly', id: { keepDaily: 2, keepWeekly: 4 }},
+ { name: '3 daily, 4 weekly, 6 monthly', id: { keepDaily: 3, keepWeekly: 4, keepMonthly: 6 }},
+ { name: '7 daily, 4 weekly, 12 monthly', id: { keepDaily: 7, keepWeekly: 4, keepMonthly: 12 }},
+ { name: 'Forever', id: { keepWithinSecs: -1 }}
+];
+
+// values correspond to cron days
+const cronDays = [
+ { id: 0, name: 'Sunday' },
+ { id: 1, name: 'Monday' },
+ { id: 2, name: 'Tuesday' },
+ { id: 3, name: 'Wednesday' },
+ { id: 4, name: 'Thursday' },
+ { id: 5, name: 'Friday' },
+ { id: 6, name: 'Saturday' },
+];
+
+// generates 24h time sets (instead of american 12h) to avoid having to translate everything to locales eg. 12:00
+const cronHours = Array.from({ length: 24 }).map(function (v, i) { return { id: i, name: (i < 10 ? '0' : '') + i + ':00' }; });
+
+function prettyBackupSchedule(pattern) {
+ if (!pattern) return '';
+ const tmp = pattern.split(' ');
+ const hours = tmp[2].split(','), days = tmp[5].split(',');
+ let prettyDay;
+ if (days.length === 7 || days[0] === '*') {
+ prettyDay = 'Everyday';
+ } else {
+ prettyDay = days.map(function (day) { return cronDays[parseInt(day, 10)].name.substr(0, 3); }).join(',');
+ }
+
+ const prettyHour = hours.map(function (hour) { return cronHours[parseInt(hour, 10)].name; }).join(',');
+ return prettyDay + ' at ' + prettyHour;
+};
+
+function prettyBackupRetention(retention) {
+ function stableStringify(obj) { return JSON.stringify(obj, Object.keys(obj).sort()); }
+ const tmp = backupRetentions.find(function (p) { return stableStringify(p.id) === stableStringify(retention); });
+ return tmp ? tmp.name : '';
+}
+
export default {
create,
+ backupRetentions,
+ cronDays,
+ cronHours,
+ prettyBackupSchedule,
+ prettyBackupRetention
};
diff --git a/dashboard/src/views/BackupSitesView.vue b/dashboard/src/views/BackupSitesView.vue
index 94024fced..2170b5033 100644
--- a/dashboard/src/views/BackupSitesView.vue
+++ b/dashboard/src/views/BackupSitesView.vue
@@ -246,6 +246,10 @@ onMounted(async () => {
{{ regionName(site.provider, site.config.endpoint) + ' ' + site.config.bucket + (site.config.prefix ? `/${site.config.prefix}` : '') }}
+
+ {{ $t('backups.schedule.schedule') }}: {{ BackupSitesModel.prettyBackupSchedule(site.schedule) }}
+ {{ $t('backups.schedule.retentionPolicy') }}: {{ BackupSitesModel.prettyBackupRetention(site.retention) }}
+
Last backup: Never
Last backup: {{ prettyLongDate(site.task.ts) }}