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
2 changes: 1 addition & 1 deletion docs/backups.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ backups = {
apps = {
enable = true;
schedule = "15 2 * * *"; # UTC
retain = { daily = 7; weekly = 4; monthly = 6; };
retain = { within = "7d"; daily = 7; weekly = 4; monthly = 6; };
volumes = [ "myns/my-claim" ]; # optional: volumes of apps that aren't webApps
};
};
Expand Down
5 changes: 4 additions & 1 deletion system/k8s/vars.nix
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,10 @@ rec {
apps = {
enable = false;
schedule = "15 2 * * *";
retain = { daily = 7; weekly = 4; monthly = 6; };
# within: every backup of the last 7 days too, not just the newest
# of each day. A restore "as of" an earlier one the same day (a
# rebuild's, before the new cluster's first) needs it still there.
retain = { within = "7d"; daily = 7; weekly = 4; monthly = 6; };
volumes = [ ]; # more volumes than webApp's: [ "<namespace>/<claim>" ]
};
};
Expand Down
16 changes: 16 additions & 0 deletions tests/vm/app-backups.nix
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,22 @@ testLib.mkVmTest {
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}')\" ]"; }
];
}
{
# A rebuild backs up, then the new cluster backs up its fresh volumes
# the same day: restoring "as of" the first must still find it
# (restic's forget keeps only the newest per day without retain.within).
name = "a restore as of an earlier backup the same day";
steps = [
{ succeed = "${notes} sh -c 'echo first > /data/hello'"; }
{ succeed = "nixlab-backup-now notes/notes-data && date -u +%Y-%m-%dT%H:%M:%SZ > /tmp/as-of"; timeout = 900; }
{ succeed = "sleep 2; ${notes} sh -c 'echo second > /data/hello'"; }
{ succeed = "nixlab-backup-now notes/notes-data"; timeout = 900; }
{ succeed = "nixlab-restore notes/notes-data --as-of $(cat /tmp/as-of) --yes"; timeout = 900; }
{ waitUntil = "${k} -n notes rollout status deploy/notes --timeout=10s"; timeout = 300; }
{ desc = "the first one's contents";
succeed = "c=$(${notes} cat /data/hello); echo \"got: $c\" >&2; [ \"$c\" = first ]"; }
];
}
];

onFailure = [
Expand Down
Loading