aboutsummaryrefslogtreecommitdiffstats
path: root/snapshot
diff options
context:
space:
mode:
Diffstat (limited to 'snapshot')
-rwxr-xr-xsnapshot15
1 files changed, 15 insertions, 0 deletions
diff --git a/snapshot b/snapshot
new file mode 100755
index 0000000..ae6a231
--- /dev/null
+++ b/snapshot
@@ -0,0 +1,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