Add bret to an existing VolSync setup
Your app’s PVCs already have restic ReplicationSource objects. Work through the list in order.
1. One ReplicationSource and one repository per PVC
Section titled “1. One ReplicationSource and one repository per PVC”- bret needs one
ReplicationSourceper PVC. That is how VolSync works anyway. - Give each PVC its own restic repository (its own Secret with its own
RESTIC_REPOSITORY). A repository shared by twoReplicationSourceobjects races on init. - Only the restic mover is supported. bret reads
spec.restic.repository. AReplicationSourcewithout it fails withRepositoryMissing.
2. The repository Secret must be in the Restore namespace
Section titled “2. The repository Secret must be in the Restore namespace”The ReplicationDestination that bret creates lives in the Restore namespace and uses the
Secret that spec.restic.repository names. If the Secret is not there, the Restore fails with
RepositoryMissing.
A RestoreTest reads ReplicationSource objects in its own namespace, so the Secret is
already there. A Restore made by hand can name a ReplicationSource in another namespace with
backupRef.namespace. Then copy the Secret into the Restore namespace.
3. Set the mover UID
Section titled “3. Set the mover UID”The restic mover writes the restored files as one UID. The check must be able to read them, and the backup mover must have been able to read the source.
- On the
ReplicationSource, setmoverSecurityContextto the owner of the data, for example999for MariaDB or PostgreSQL. With the default UID, the backup fails withpermission deniedon a database data dir. - 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,65534.
- the check annotation
metadata: annotations: bret.linogics.io/mover-uid: '{"data": 999}'4. Know which backup bret picks
Section titled “4. Know which backup bret picks”- Object: the
ReplicationSourcein theRestoreTestnamespace. backupSelector.namepicks one.labelsmust match exactly one. More than one blocks the test withBackupSelectorAmbiguous, naming the matches.- The backup is the last sync:
status.lastSyncTime. A source that never synced blocks withBackupNotFound. - afterBackup starts a run when every source has a newer
lastSyncTimethan the last run.
kubectl -n shop get replicationsource \ -o custom-columns=NAME:.metadata.name,PVC:.spec.sourcePVC,REPO:.spec.restic.repository,SYNC:.status.lastSyncTime5. Enable the provider in the bret chart
Section titled “5. Enable the provider in the bret chart”providers: volsync: enabled: trueThe chart grants get, list, watch on replicationsources and get, list, watch,
create, delete, patch on replicationdestinations in volsync.backube, plus get on
Secrets.
6. Write a check and a RestoreTest
Section titled “6. Write a check and a RestoreTest”A minimal check that tests that a file exists and is not empty:
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: volsync sources: - sourcePVC: data backupSelector: name: data autoExpand: percentage: 20 restoreCheckRef: name: shop triggers: afterBackup: delay: 30m manual: trueWithout size, bret sizes the scratch PVC from the source with autoExpand: by default 10
percent headroom and at least 1Gi. Here the headroom is 20 percent. Details:
Scratch volume size.
7. Run it once and read the result
Section titled “7. Run it once and read the result”A sync that finished before the RestoreTest existed 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
VolSync limitations.
