]> arthur.barton.de Git - backup-script.git/commitdiff
CloneSubvolume: Introduce $snapshot parameter
authorAlexander Barton <alex@barton.de>
Wed, 29 Jul 2015 08:31:05 +0000 (10:31 +0200)
committerAlexander Barton <alex@barton.de>
Wed, 29 Jul 2015 08:31:39 +0000 (10:31 +0200)
This is in preparation for ZFS support.

bin/backup-script

index 478e505f9795f9bff02d47990abb8f522bca2449..457a5e7be4a1bdbbc47702be179894da77ef0b03 100755 (executable)
@@ -132,6 +132,7 @@ CreateSubvolume() {
 CloneSubvolume() {
        local source="$1"
        local volume="$2"
+       local snapshot="$3"
        local dir
        local fs
 
@@ -139,7 +140,7 @@ CloneSubvolume() {
        fs=$(GetFS "$source")
        case "$fs" in
          "btrfs")
-               btrfs subvolume snapshot "$source" "$volume"  >/dev/null || return 1
+               btrfs subvolume snapshot "$source" "$snapshot"  >/dev/null || return 1
                ;;
          *)
                echo "CloneSubvolume: Incompatible FS type \"$fs\" on \"$source\"!"
@@ -339,6 +340,7 @@ for f in $sys; do
                        fi
                fi
                sys_target="$sys_target/$(date +%Y%m%d-%H%M%S)"
+               snapshot="$sys_target"
 
                if [ -n "$last" -a ! -e "$last/.stamp" ]; then
                        # Old backup directory without "stamp file", continue
@@ -352,12 +354,12 @@ for f in $sys; do
                        # Old backup directory found, create new snapshot
                        echo "Found last snapshot in \"$last\"."
                        if [ "$DRYRUN" -eq 0 ]; then
-                               CloneSubvolume "$last" "$sys_target"; r=$?
+                               CloneSubvolume "$last" "$sys_target" "$snapshot"; r=$?
                                if [ $r -ne 0 ]; then
-                                       echo "Can't create snapshot \"$sys_target\" of \"$last\", code $r!? \"$system\" skipped!"
+                                       echo "Can't create snapshot \"$snapshot\" of \"$last\", code $r!? \"$system\" skipped!"
                                        echo; continue
                                fi
-                               echo "Created new snapshot in \"$sys_target\"."
+                               echo "Created new snapshot in \"$snapshot\"."
                        else
                                echo " *** Trial run, not creating new snapshot in \"$sys_target\"!"
                        fi