Skip to content

Add ephemeral volume type for SnapshotPolicy sources #295

Description

@kasefuchs

What problem are you trying to solve?

I need to backup external data (for example an S3 bucket) using runJob hooks.

Right now SnapshotPolicy only accepts existing PVCs in spec.sources, so I have to create a temporary PVC just for the backup. After that it is no longer needed, but it still has to be managed and cleaned up.

Proposed solution

Add an ephemeral source type to spec.sources.

Kopiur could create a temporary PVC before the Snapshot, mount it into the backup hooks, and remove it after the Snapshot.

Example:

apiVersion: kopiur.home-operations.com/v1alpha1
kind: SnapshotPolicy
metadata:
  name: nextcloud-garage
spec:
  repository:
    kind: ClusterRepository
    name: shared
  credentialProjection:
    enabled: true
  copyMethod: Direct
  sources:
    - ephemeral:
        size: 50Gi
  hooks:
    beforeSnapshot:
      - runJob:
          jobSpec:
            template:
              spec:
                restartPolicy: Never
                containers:
                  - name: backup
                    image: amazon/aws-cli:latest
                    envFrom:
                      - secretRef:
                          name: nextcloud-garage-key
                    command:
                      - aws
                      - s3
                      - sync
                      - s3://nextcloud
                      - /backup
                    volumeMounts:
                      - name: backup
                        mountPath: /backup
                volumes:
                  - name: backup
                    persistentVolumeClaim:
                      claimName: <generated pvc name?>
  retention:
    keepLatest: 3
    keepDaily: 7
    keepWeekly: 2
  compression:
    compressor: zstd

Alternatives considered

Using a regular PVC and cleaning it up in an afterSnapshot hook.

This works, but requires creating and managing a PVC that is only needed for a single snapshot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions