Skip to content

Commit

Permalink
feat(xo-web/backup): long-term retention settings
Browse files Browse the repository at this point in the history
  • Loading branch information
pdonias committed Nov 19, 2024
1 parent 9939cee commit 5f21abe
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
> Users must be able to say: “Nice enhancement, I'm eager to test it”
- [Proxies] Display the current proxy version (PR [#8104](https://github.com/vatesfr/xen-orchestra/pull/8104))
- [Backup] Long-term retention

### Bug fixes

Expand Down
8 changes: 6 additions & 2 deletions packages/xo-web/src/common/intl/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,11 @@ const messages = {
cbtDestroySnapshotDataDisabledInformation:
'Snapshot data can be purged only when NBD is enabled and rolling snapshot is not used',
shorterBackupReports: 'Shorter backup reports',
longTermRetention: 'Long-term retention of backups',
numberOfDailyBackupsKept: 'Number of daily backups kept',
numberOfWeeklyBackupsKept: 'Number of weekly backups kept',
numberOfMonthlyBackupsKept: 'Number of monthly backups kept',
numberOfYearlyBackupsKept: 'Number of yearly backups kept',

// ------ New Remote -----
newRemote: 'New file system remote',
Expand Down Expand Up @@ -1523,8 +1528,7 @@ const messages = {
ha: 'HA',
srHaTooltip: 'SR used for High Availability',
nestedVirt: 'Nested virtualization',
nestedVirtualizationWarning:
'Unstable feature, insecure for the host, usage is discouraged. Click for more details.',
nestedVirtualizationWarning: 'Unstable feature, insecure for the host, usage is discouraged. Click for more details.',
vmAffinityHost: 'Affinity host',
vmNeedToBeHalted: 'The VM needs to be halted',
vmVga: 'VGA',
Expand Down
62 changes: 62 additions & 0 deletions packages/xo-web/src/xo-app/backup/new/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,18 @@ const New = decorate([
reportRecipients: (reportRecipients.splice(key, 1), reportRecipients),
})
},
setLongTermRetention({ setGlobalSettings }, retention, granularity) {
const { propSettings, settings = propSettings } = this.state
const longTermRetention = settings.getIn(['', 'longTermRetention']) ?? {}

if (retention > 0) {
longTermRetention[granularity] = { retention, settings: {} }
} else {
delete longTermRetention[granularity]
}

setGlobalSettings({ longTermRetention: isEmpty(longTermRetention) ? undefined : longTermRetention })
},
setReportWhen:
({ setGlobalSettings }, { value }) =>
() => {
Expand Down Expand Up @@ -679,6 +691,10 @@ const New = decorate([
inputNRetriesVmBackupFailures: generateId,
inputBackupReportTplId: generateId,
inputTimeoutId: generateId,
inputLongTermRetentionDaily: generateId,
inputLongTermRetentionWeekly: generateId,
inputLongTermRetentionMonthly: generateId,
inputLongTermRetentionYearly: generateId,

// In order to keep the user preference, the offline backup is kept in the DB
// and it's considered active only when the full mode is enabled
Expand Down Expand Up @@ -789,6 +805,7 @@ const New = decorate([
checkpointSnapshot,
concurrency,
fullInterval,
longTermRetention = {},
maxExportRate,
nbdConcurrency = 1,
nRetriesVmBackupFailures = 0,
Expand Down Expand Up @@ -1244,6 +1261,51 @@ const New = decorate([
</CardBlock>
</Card>
<Schedules />
<Card>
<CardHeader>{_('longTermRetention')}</CardHeader>
<CardBlock>
<FormGroup>
<label htmlFor={state.inputLongTermRetentionDaily}>
<strong>{_('numberOfDailyBackupsKept')}</strong>
</label>
<Number
id={state.inputLongTermRetentionDaily}
onChange={value => effects.setLongTermRetention(value, 'daily')}
value={longTermRetention.daily?.retention}
/>
</FormGroup>
<FormGroup>
<label htmlFor={state.inputLongTermRetentionWeekly}>
<strong>{_('numberOfWeeklyBackupsKept')}</strong>
</label>
<Number
id={state.inputLongTermRetentionWeekly}
onChange={value => effects.setLongTermRetention(value, 'weekly')}
value={longTermRetention.weekly?.retention}
/>
</FormGroup>
<FormGroup>
<label htmlFor={state.inputLongTermRetentionMonthly}>
<strong>{_('numberOfMonthlyBackupsKept')}</strong>
</label>
<Number
id={state.inputLongTermRetentionMonthly}
onChange={value => effects.setLongTermRetention(value, 'monthly')}
value={longTermRetention.monthly?.retention}
/>
</FormGroup>
<FormGroup>
<label htmlFor={state.inputLongTermRetentionYearly}>
<strong>{_('numberOfYearlyBackupsKept')}</strong>
</label>
<Number
id={state.inputLongTermRetentionYearly}
onChange={value => effects.setLongTermRetention(value, 'yearly')}
value={longTermRetention.yearly?.retention}
/>
</FormGroup>
</CardBlock>
</Card>
</Col>
</Row>
<Row>
Expand Down

0 comments on commit 5f21abe

Please sign in to comment.