This commit is contained in:
jarek committed 2026-07-26 10:27:12 +02:00
1 parent 123e04d17f
commit 49809865dc
16 files changed
+427 -259

No files matched your search

+7 -3
View File
@@ -42,10 +42,14 @@ export interface MetadataFile {
* tag/exclude/flag-assembled by the caller.
*/
export function buildBackupScript(resticArgs: string[]): string {
// Turn off `set -e` for the restic step so exit 3 (partial) doesn't abort
// before the marker is printed; the marker carries the real code.
// restic runs backgrounded so the SIGINT-forwarding trap can reach it on cancel
// (SIGINT lets restic release its repo lock; a SIGKILL orphans it and hangs the
// next backup on --retry-lock). The kill-0 re-wait loop only fires when a signal
// interrupted the first `wait` early; a normal exit skips it, keeping restic's
// real code (0/3) for the marker.
const restic = `restic ${resticArgs.map(shellQuote).join(' ')}`;
return `mkdir -p /metadata; set +e; ${finishScript(restic)}`;
const step = `${restic} & __rpid=$!; trap 'kill -INT $__rpid 2>/dev/null' INT TERM; wait $__rpid; __rc=$?; while kill -0 $__rpid 2>/dev/null; do wait $__rpid; __rc=$?; done; ( exit $__rc )`;
return `mkdir -p /metadata; set +e; ${finishScript(step)}`;
}
/**