aboutsummaryrefslogtreecommitdiffstats
path: root/snapshot
blob: e22a73f9f83470b081e0c3d4d139cc95d0e8c16b (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 snaphot of %s in %s\n" "$from" "$to" ||
	    printf "==> Failet to create a snaphot 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 "$@"