diff options
-rwxr-xr-x | src/push-btrfs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/push-btrfs b/src/push-btrfs index 41ffd7f..135de34 100755 --- a/src/push-btrfs +++ b/src/push-btrfs | |||
@@ -17,7 +17,7 @@ check_dependencies() | |||
17 | { | 17 | { |
18 | for c in flock jq btrfs pv realpath stat egrep date mv ln rm | 18 | for c in flock jq btrfs pv realpath stat egrep date mv ln rm |
19 | do | 19 | do |
20 | command -v $c >/dev/null | 20 | command -v "$c" >/dev/null || die "missing dependency: $c" |
21 | done | 21 | done |
22 | } | 22 | } |
23 | 23 | ||
@@ -45,7 +45,8 @@ get_age() | |||
45 | 45 | ||
46 | btrfs_receive() | 46 | btrfs_receive() |
47 | { | 47 | { |
48 | ssh -- "${1%%:*}" btrfs receive -- "${1#*:}" | 48 | ssh_cmdline=(ssh -- "${1%%:*}") |
49 | "${ssh_cmdline[@]}" bash -c $(printf %q 'set -x; ([ -d "$0" ] || mkdir -p "$0") && btrfs receive -- "$0"') $(printf %q "${1#*:}") | ||
49 | } | 50 | } |
50 | 51 | ||
51 | set -e | 52 | set -e |
@@ -100,7 +101,7 @@ fi | |||
100 | 101 | ||
101 | new_snapshot=${src%/}/.snapshot~$(date -Ins) | 102 | new_snapshot=${src%/}/.snapshot~$(date -Ins) |
102 | btrfs subvolume snapshot -r -- "$src" "$new_snapshot" | 103 | btrfs subvolume snapshot -r -- "$src" "$new_snapshot" |
103 | if ! btrfs send ${remote_head:+ -p "$remote_head"} -- "$new_snapshot" | pv | btrfs_receive "$dst" | 104 | if ! btrfs send ${remote_head:+ -p "$remote_head"} -- "$new_snapshot" | btrfs_receive "$dst" |
104 | then | 105 | then |
105 | btrfs subvolume delete "$new_snapshot" | 106 | btrfs subvolume delete "$new_snapshot" |
106 | exit 1 | 107 | exit 1 |