about summary refs log tree commit diff
path: root/bundles/restic-backup/files/resticrestore
blob: 68a10f1f99d1e69dcba5995b99c3c3370fae9272 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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"