summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2023-05-28 19:54:57 -0400
committerAndrew Cady <d@jerkface.net>2023-05-28 19:54:57 -0400
commit30e67c848e40524eee11f860baeb59dd9e59df93 (patch)
tree9eff4085d679b63a01f200f6bbc07182c628c1be
parentad80d194fd63fc327eb161236ee1750b76838d03 (diff)
push-btrfs improvements
-rwxr-xr-xsrc/push-btrfs7
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
46btrfs_receive() 46btrfs_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
51set -e 52set -e
@@ -100,7 +101,7 @@ fi
100 101
101new_snapshot=${src%/}/.snapshot~$(date -Ins) 102new_snapshot=${src%/}/.snapshot~$(date -Ins)
102btrfs subvolume snapshot -r -- "$src" "$new_snapshot" 103btrfs subvolume snapshot -r -- "$src" "$new_snapshot"
103if ! btrfs send ${remote_head:+ -p "$remote_head"} -- "$new_snapshot" | pv | btrfs_receive "$dst" 104if ! btrfs send ${remote_head:+ -p "$remote_head"} -- "$new_snapshot" | btrfs_receive "$dst"
104then 105then
105 btrfs subvolume delete "$new_snapshot" 106 btrfs subvolume delete "$new_snapshot"
106 exit 1 107 exit 1