about summary refs log tree commit diff
path: root/bundles/restic-backup/files/resticrestore
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/restic-backup/files/resticrestore')
-rw-r--r--bundles/restic-backup/files/resticrestore29
1 files changed, 29 insertions, 0 deletions
diff --git a/bundles/restic-backup/files/resticrestore b/bundles/restic-backup/files/resticrestore
new file mode 100644
index 0000000..68a10f1
--- /dev/null
+++ b/bundles/restic-backup/files/resticrestore
@@ -0,0 +1,29 @@
+#!/bin/sh
+set -eu
+
+backup_tag=foobar
+backup_restore_snapshot=latest
+
+main() {
+	# remove stale locks
+	resticw unlock
+
+	# run restore
+	resticw restore \
+		--verify \
+		--tag "${backup_tag}" \
+		--include "${1:-*}" \
+		--target / \
+		"${backup_restore_snapshot}"
+
+	# TODO: restic check
+	# TODO: dump stats to file in metrics format to /run/prom/restic
+}
+
+exit_hook() {
+	resticw unlock
+}
+trap exit_hook INT EXIT
+
+[ "$1" = "-h" ] && printf 'usage: resticrestore [TARGET]\n\n' && exit 0
+main "$1"