aboutsummaryrefslogtreecommitdiffstats
path: root/snapshot
blob: ae6a2310d26b5c8deaa0ba041de0898b98d9c3fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/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"
}

SNAPSHOTS=/snapshots
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