feat: add Restic and Kopia VM backups (#1226)

* feat: add Restic and Kopia VM backups

Add a type to Take Backup so VMs on third-party storage or Longhorn v2
can be backed up to S3. Native stays on the backup action, which has no
type field. Restic and Kopia create the VirtualMachineBackup directly.

Types a VM can't use stay in the dropdown, disabled, with the reason.

Treat Restic and Kopia as remote backups in the restore routes, the
schedule filter and the snapshot list. Show the type in the backup list.

Add a form for the third-party-backup-config setting and the Kopia
garbage collection option on the backup target, and stop resetting
virtualHostedStyle when the backup target form opens.

All of it sits behind a v1.10 feature flag.

Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com>

* fix: refine Take Backup for NFS targets and non-admin users

Hide Take Backup on VMs that only have the snapshot action when the
backup target is known not to be S3. Nothing can back those VMs up
there, so they match the menu on main again.

Only block Restic and Kopia on a backup target type the user can read.
Non-admin users can't read the backup-target setting, so they were
always told an S3 target was required. The webhook still decides.

List why a type is unavailable under the Type select. Disabled options
can't be reached by keyboard, so the reasons inside them were hidden
from screen readers.

Fall back to the default when third-party-backup-config doesn't parse,
like the other settings forms, instead of showing a parse error banner.

Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com>

* fix: tighten Take Backup and backup config inputs after review

- Offer Take Backup without the backup action only on VMs whose volumes
  Restic and Kopia support. The snapshot action isn't gated on a backup
  target, so users who can't read backup-target saw the menu on every VM.
- Take the third-party-backup-config sizes in MiB, so a bare number is no
  longer saved as bytes.
- Merge csi-driver-config value and default like the backend does, with
  the default's entries winning.

Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com>

* feat: add the Restic and Kopia switch to the backup target

The backend now rejects Restic and Kopia backups unless the S3 backup
target has thirdPartyBackupEnabled set, and it is off by default. While
it is on, every save of the target needs the repository password.

- Add an "Enable Restic and Kopia Backups" checkbox to the S3 backup
  target form, dropped on NFS like Kopia garbage collection.
- Show a required Repository Password field while the switch is on, and
  drop the password when the switch is off or the target is NFS, where
  the backend rejects it.
- When the target is readable and the switch is off, Restic and Kopia
  are unavailable with a reason, after any volume reason, and Take
  Backup follows the same rule.
- Rename the feature flag getter in the form and the dialog so it isn't
  confused with the setting field.

Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com>

* fix: offer Kopia garbage collection only while Restic and Kopia are on

The backend removes the Kopia maintenance jobs whenever Restic and Kopia
are turned off, so the option could be saved as on while nothing ran.
Show it only while the switch is ticked, and drop it from the setting
when the switch is turned off, like the repository password.

Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com>

---------

Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com>
This commit is contained in:
Marcelo Fukumoto authored and GitHub committed 2026-11-23 14:42:45 +01:00
1 parent 1b562cec41
commit 0a49829658
19 files changed
+1142 -72

No files matched your search

+37
View File
@@ -96,6 +96,7 @@ harvester:
backup:
success: 'Backup { backUpName } has been initiated.'
addBackup: Add Backup
noTypeAvailable: No backup type can protect this virtual machine.
fileSystemFreezeDeadline:
label: 'File System Freeze Deadline'
quota:
@@ -1360,6 +1361,31 @@ harvester:
label: Refresh Interval
tip: The interval for the backup target to sync data to [[Harvester]] cluster. Set to 0 to disable refresh mechanism.
backupTargetTip: The endpoint used to access the backupstore. NFS and S3 are supported.
thirdPartyBackup:
label: Enable Restic and Kopia Backups
tooltip: Allows Restic and Kopia virtual machine backups to this S3 target. Native backups and snapshots are not affected.
password:
label: Repository Password
tip: Restic and Kopia encrypt their backups with this password. Enter it every time you save this setting. It can't be changed for an existing repository, so keep a copy.
kopiaGC:
label: Enable Kopia Garbage Collection
tooltip: Runs scheduled Kopia maintenance to remove unused data from the S3 repository.
type:
backup: Native
snapshot: Snapshot
restic: Restic
kopia: Kopia
typeUnavailable:
native: Not supported by the volumes of this virtual machine.
longhornV2: Not supported on Longhorn V2 volumes such as {volume}.
cdi: Not supported on volumes created from a CDI image such as {volume}.
noBackupSnapshotClass: Set a backup volume snapshot class for {driver} in the csi-driver-config setting.
requiresS3: Requires an S3 backup target.
requiresBlock: Requires Block volume mode, but {volume} uses Filesystem.
longhornV1: Not supported on Longhorn V1 volumes such as {volume}.
noSnapshotClass: Set a volume snapshot class for {driver} in the csi-driver-config setting.
snapshot: The volumes of this virtual machine cannot be snapshotted.
thirdPartyBackupOff: Not enabled in the backup-target setting.
message:
noSetting:
prefix: You must configure the backup target
@@ -1955,6 +1981,16 @@ harvester:
allowWorkloadDisruption: "Allow Workload Disruption"
disableTLS: "Disable TLS"
matchSELinuxLevelOnMigration: "Match SELinux Level On Migration"
thirdPartyBackupConfig:
memoryRequest: Memory Request
memoryLimit: Memory Limit
ephemeralRequest: Ephemeral Storage Request
ephemeralLimit: Ephemeral Storage Limit
cacheSize: Cache Size
cacheSizeHint: Must be less than the ephemeral storage limit.
maxConcurrentJobs: Maximum Concurrent Jobs
maxConcurrentJobsHint: Set to 0 for no limit.
noCache: Disable Cache
cloudTemplate:
label: Cloud Configuration Templates
@@ -2853,6 +2889,7 @@ advancedSettings:
'harv-rancher-cluster': 'Configure Rancher cluster integration settings for guest cluster management.'
'harv-max-hotplug-ratio': 'The ratio for kubevirt to limit the maximum CPU and memory that can be hotplugged to a VM. The value could be an integer between 1 and 20, default to 4.'
'harv-kubevirt-migration': 'Configure cluster-wide KubeVirt live migration parameters.'
'harv-third-party-backup-config': 'Configure the resources and concurrency of Restic and Kopia virtual machine backup jobs.'
'harv-instance-manager-resources': 'Configure resource percentage reservations for Longhorn instance manager V1 and V2. Valid instance manager CPU range between 0 - 40.'
'harv-cluster-pod-security-standard': 'Enforce Kubernetes Pod Security Standards (PSS) at the cluster level.'
'harv-maintenance-mode-drain-timeout': 'Maintenance mode drain timeout in minutes. Use 0 to disable the timeout.'