aboutsummaryrefslogtreecommitdiffstats
path: root/snapshot
blob: e2723a7cc13b41524280c018bb8bc085b0303104 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env bash

create_snapshot() {
	local from="$1"
	local to="$2"/"$(date +%Y-%m-%dT%H:%M:%S%z)"
	sudo mkdir "$to"
	sudo btrfs subvolume snapshot -r "$from" "$to" &&
	    printf "==> Successfully created a snapshot of %s in %s\n" "$from" "$to" ||
	    printf "==> Failed to create a snapshot of %s in %s\n"     "$from" "$to"
}


main() {
	local rootmount=/media/"$SHORTHOST"-ssd-1
	printf "==> Creating snapshots in %s\n" "$rootmount"

	create_snapshot "$rootmount"/root "$rootmount"/snap-root
	create_snapshot "$rootmount"/home "$rootmount"/snap-home
}


main "$@"