summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2023-06-03 17:35:46 -0400
committerAndrew Cady <d@jerkface.net>2023-06-03 17:35:46 -0400
commitbba6b0a3f486550f666f7a3963c509402198b655 (patch)
tree88b2db16151d8f426ec15e643324d0c8e04e03ca
parent354acca1bfaf06ec7c0d44182ef3869d36a7fb3a (diff)
remove .json conf file if source subvolume is readonly (push-btrfs will not send it in that case)
-rwxr-xr-xsrc/push-btrfs-scan19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/push-btrfs-scan b/src/push-btrfs-scan
index bc97d00..06c5d42 100755
--- a/src/push-btrfs-scan
+++ b/src/push-btrfs-scan
@@ -40,13 +40,14 @@ is_our_snapshot()
40 40
41filter_readonly() 41filter_readonly()
42{ 42{
43 if btrfs subvolume show -r "$id" / | sed -Ene '/^\tFlags:.*\breadonly\b/{p;q1}' -e '$q' 43 if btrfs subvolume show -r "$id" / | sed -Ene '/^\tFlags:.*\breadonly\b/q' -e '$q1'
44 then 44 then
45 if [ -e "$conf_name" ] 45 if [ -e "$conf_name" ]
46 then 46 then
47 printf '%20s %s\n' delete "$conf_name" >&2 47 printf '%20s %s\n' rm "$conf_name" >&2
48 rm "$conf_name"
48 fi 49 fi
49 printf '%20s %s\n' '(snapshot) lose' "$path_fixed" >&2 50 printf '%20s %s\n' '(readonly) lose' "$path_fixed" >&2
50 return 51 return
51 fi 52 fi
52 "$@" 53 "$@"
@@ -58,7 +59,8 @@ filter_snapshot_filename()
58 then 59 then
59 if [ -e "$conf_name" ] 60 if [ -e "$conf_name" ]
60 then 61 then
61 printf '%20s %s\n' delete "$conf_name" >&2 62 printf '%20s %s\n' rm "$conf_name" >&2
63 rm "$conf_name"
62 fi 64 fi
63 printf '%20s %s\n' '(snapshot) lose' "$path_fixed" >&2 65 printf '%20s %s\n' '(snapshot) lose' "$path_fixed" >&2
64 return 66 return
@@ -90,7 +92,7 @@ filter_blacklist()
90 printf '%20s %s\n' '(blacklist) lose' "$path_fixed" >&2 92 printf '%20s %s\n' '(blacklist) lose' "$path_fixed" >&2
91 if [ -e "$conf_name" ] 93 if [ -e "$conf_name" ]
92 then 94 then
93 printf '%20s %s\n' delete "$conf_name" >&2 95 printf '%20s %s\n' rm "$conf_name" >&2
94 rm "$conf_name" 96 rm "$conf_name"
95 fi 97 fi
96 timer=$destination_host$(systemd-escape "$path_fixed").timer 98 timer=$destination_host$(systemd-escape "$path_fixed").timer
@@ -188,4 +190,9 @@ esac
188 190
189ssh root@"$destination_host" true || read -p 'Could not log in. Continue? ' 191ssh root@"$destination_host" true || read -p 'Could not log in. Continue? '
190 192
191with_subvolumes fixup_path compute_paths filter_snapshot_filename filter_blacklist mirror 193with_subvolumes fixup_path \
194 compute_paths \
195 filter_snapshot_filename \
196 filter_readonly \
197 filter_blacklist \
198 mirror