Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions system/k8s/app-backups-tools.nix
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ in
echo "restoring ..."
wait_for replicationdestination "$dest" "$now"
kubectl -n "$ns" delete replicationdestination "$dest" >/dev/null
# The restore can leave its restic lock in the repository, and every
# later backup then fails at "forget" ("repository is already
# locked"): its next run unlocks first.
kubectl -n "$ns" patch replicationsource "$claim" --type merge -p "{\"spec\":{\"restic\":{\"unlock\":\"$now\"}}}" >/dev/null
echo "restored $ns/$claim; starting its apps again"
'';
};
Expand Down
5 changes: 5 additions & 0 deletions tests/vm/app-backups.nix
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ testLib.mkVmTest {
{ waitUntil = "${k} -n notes rollout status deploy/notes --timeout=10s"; timeout = 300; }
{ desc = "the backed-up contents, and the app running again";
succeed = "[ \"$(${notes} cat /data/hello)\" = backed-up ]"; }
{ desc = "the next backup unlocks the repository first (a restore can leave its lock)";
succeed = "[ -n \"$(${k} -n notes get replicationsource notes-data -o jsonpath='{.spec.restic.unlock}')\" ]"; }
{ succeed = "nixlab-backup-now notes/notes-data"; timeout = 900; }
{ desc = "and succeeds";
succeed = "[ \"$(${k} -n notes get replicationsource notes-data -o jsonpath='{.status.latestMoverStatus.result}')\" = Successful ] && [ -n \"$(${k} -n notes get replicationsource notes-data -o jsonpath='{.status.restic.lastUnlocked}')\" ]"; }
];
}
];
Expand Down
Loading