Add bret to an existing Kopiur setup
Your app’s PVCs already have Kopiur SnapshotPolicy objects. Work through the list in order.
1. One SnapshotPolicy per PVC
Section titled “1. One SnapshotPolicy per PVC”- One
Snapshotholds one PVC. Give each PVC its ownSnapshotPolicywith onepvc:source. - Several policies can share one
Repository. - Kopiur labels each
Snapshotwithkopiur.home-operations.com/config: <policy>. With one policy per PVC, that label selects theSnapshotsof exactly one PVC. It is the usual label forbackupSelector.labels.
kubectl -n shop get snapshot --show-labels2. The credentials Secret must be in the Restore namespace
Section titled “2. The credentials Secret must be in the Restore namespace”A Kopiur Restore runs in the Restore namespace and reads the repository credentials Secret
there. Kopiur does not find the Secret in another namespace, and the restore fails with
MissingCredentialsSecret. Keep the Secret that the Repository names next to the app.
3. Set the mover UID
Section titled “3. Set the mover UID”The Kopia mover runs as UID 65532 by default. A database data dir with mode 0700 is unreadable for it.
- On the
SnapshotPolicy, setspec.mover.securityContext.runAsUserto the owner of the data, for example999for MariaDB or PostgreSQL. Otherwise the snapshot fails withPermissionDenied. - On the restore side, bret picks the mover UID per source in this order:
- the check annotation
bret.linogics.io/mover-uid, a JSON map keyed bysourcePVC, runAsUserof the first check container that sets one,- none, so Kopiur uses its default.
- the check annotation
metadata: annotations: bret.linogics.io/mover-uid: '{"data": 999}'4. Know which Snapshot bret picks
Section titled “4. Know which Snapshot bret picks”- Object: Kopiur
Snapshotin theRestoreTestnamespace. backupSelector.namepicks oneSnapshot.labelspicks everySnapshotwith those labels.- Counts when:
status.phaseisSucceeded. - Newest:
lastTransitionTimeof theReady=Truecondition. - afterBackup starts a run when every source has a newer
Snapshotthan the last run.
5. Enable the provider in the bret chart
Section titled “5. Enable the provider in the bret chart”Kopiur is on by default. To be explicit:
providers: kopiur: enabled: trueThe chart grants get, list, watch on snapshots, get on snapshotpolicies, and full
rights on restores in kopiur.home-operations.com.
6. Write a check and a RestoreTest
Section titled “6. Write a check and a RestoreTest”apiVersion: bret.linogics.io/v1alpha1kind: RestoreCheckmetadata: name: shop namespace: shop annotations: bret.linogics.io/mover-uid: '{"data": 1000}'spec: restoredVolumes: - sourcePVC: data mountPath: /data containers: - name: check image: busybox:1.37 command: ["sh", "-c", "test -s /data/orders.db"]apiVersion: bret.linogics.io/v1alpha1kind: RestoreTestmetadata: name: shop namespace: shopspec: provider: kopiur sources: - sourcePVC: data backupSelector: labels: kopiur.home-operations.com/config: data restoreCheckRef: name: shop triggers: afterBackup: delay: 30m manual: true7. Run it once and read the result
Section titled “7. Run it once and read the result”A Snapshot older than the RestoreTest never starts an afterBackup run. Start the first run
by hand:
kubectl -n shop annotate --overwrite restoretest/shop bret.linogics.io/run-now="$(date +%s)"kubectl -n shop get restore -wkubectl -n shop describe restore <name>Succeeded means the check exited 0. For Failed, look up the condition reason in
Failure reasons and
Kopiur limitations.
