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

create_snapshot() {
	sudo btrfs subvolume snapshot -r "$1" "$2" &&
	    printf "==> Successfully created a snaphot of %s in %s\n" "$1" "$2" ||
	    printf "==> Failet to create a snaphot of %s in %s\n" "$1" "$2"
}


main() {
	local SNAPSHOTS=/snapshots
	local SNAPDIR="$SNAPSHOTS"/"$(date +%Y-%m-%dT%H:%M:%S%z)"
	printf "==> Creating snapshots in %s\n" "$SNAPDIR"

	sudo mkdir "$SNAPDIR"
	create_snapshot / "$SNAPDIR"/root
	create_snapshot /home "$SNAPDIR"/home
}


main "$@"