Browse Source

Script to find unsupported Borg options in borgmatic, to assist with #13.

Dan 1 year ago
parent
commit
24c196d2a4
1 changed files with 47 additions and 0 deletions
  1. 47
    0
      scripts/find-unsupported-borg-options

+ 47
- 0
scripts/find-unsupported-borg-options View File

@@ -0,0 +1,47 @@
1
+#!/bin/bash
2
+
3
+# For each Borg sub-command that borgmatic uses, print out the Borg flags that borgmatic does not
4
+# appear to support yet. This script isn't terribly robust. It's intended as a basic tool to ferret
5
+# out unsupported Borg options so that they can be considered for addition to borgmatic.
6
+
7
+# Generate a sample borgmatic configuration with all options set.
8
+generate-borgmatic-config --destination temp.yaml
9
+
10
+# For each sub-command (prune, create, and check), collect the Borg command-line flags that result
11
+# from running borgmatic with the generated configuration. Then, collect the full set of available
12
+# Borg flags as reported by "borg --help" for that sub-command. Finally, compare the two lists of
13
+# flags to determine which Borg flags borgmatic doesn't yet support.
14
+for sub_command in prune create check; do
15
+    echo "********** borg $sub_command **********"
16
+
17
+    for line in $(borgmatic --config temp.yaml --$sub_command -v 2 2>&1 | grep "borg $sub_command") ; do
18
+        echo "$line" | grep '^-' >> borgmatic_borg_flags
19
+    done
20
+    sort borgmatic_borg_flags > borgmatic_borg_flags.sorted
21
+    mv borgmatic_borg_flags.sorted borgmatic_borg_flags
22
+
23
+    for line in $(borg $sub_command --help | awk -v RS= '/^usage:/') ; do
24
+        # Exclude a bunch of flags that borgmatic actually supports, but don't get exercised by the
25
+        # generated sample config, and also flags that don't make sense to support.
26
+        echo "$line" | grep -- -- | sed -r 's/(\[|\])//g' \
27
+            | grep -v '^-h$' \
28
+            | grep -v '^--archives-only$' \
29
+            | grep -v '^--repository-only$' \
30
+            | grep -v '^--stats$' \
31
+            | grep -v '^--list$' \
32
+            | grep -v '^--critical$' \
33
+            | grep -v '^--error$' \
34
+            | grep -v '^--warning$' \
35
+            | grep -v '^--info$' \
36
+            | grep -v '^--debug$' \
37
+            >> all_borg_flags
38
+    done
39
+    sort all_borg_flags > all_borg_flags.sorted
40
+    mv all_borg_flags.sorted all_borg_flags
41
+
42
+    comm -13 borgmatic_borg_flags all_borg_flags
43
+
44
+    rm ./*_borg_flags
45
+done
46
+
47
+rm temp.yaml

Loading…
Cancel
Save