From e267612dc5095a0aa37b8a7320d8ca071447fd5c Mon Sep 17 00:00:00 2001 From: Johannes Löthberg Date: Tue, 8 Sep 2015 12:29:01 +0200 Subject: snapshot: Update script based on zorg changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Johannes Löthberg --- snapshot | 19 ++++++++++--------- 1 file 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 } -- cgit v1.2.3-54-g00ecf