aboutsummaryrefslogtreecommitdiffstats
path: root/snapshot
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2015-09-08 12:29:01 +0200
committerJohannes Löthberg <johannes@kyriasis.com>2015-09-08 12:29:01 +0200
commite267612dc5095a0aa37b8a7320d8ca071447fd5c (patch)
tree5523c26ba720111a7400ae0a2c3a76beb84d5bce /snapshot
parent0b567b9cfeb8b3d022147f7acc00647946746ff9 (diff)
downloadbin-e267612dc5095a0aa37b8a7320d8ca071447fd5c.tar.xz
snapshot: Update script based on zorg changes
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Diffstat (limited to 'snapshot')
-rwxr-xr-xsnapshot19
1 files changed, 10 insertions, 9 deletions
diff --git a/snapshot b/snapshot
index 01722aa..e22a73f 100755
--- a/snapshot
+++ b/snapshot
@@ -1,20 +1,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"
+ 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 SNAPSHOTS=/snapshots
- local SNAPDIR="$SNAPSHOTS"/"$(date +%Y-%m-%dT%H:%M:%S%z)"
- printf "==> Creating snapshots in %s\n" "$SNAPDIR"
+ local rootmount=/media/"$SHORTHOST"-ssd-1
+ printf "==> Creating snapshots in %s\n" "$rootmount"
- sudo mkdir "$SNAPDIR"
- create_snapshot / "$SNAPDIR"/root
- create_snapshot /home "$SNAPDIR"/home
+ create_snapshot "$rootmount"/root "$rootmount"/snap-root
+ create_snapshot "$rootmount"/home "$rootmount"/snap-home
}