find-unsupported-borg-options 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. set -o nounset
  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. # Generate a sample borgmatic configuration with all options set, and uncomment all options.
  7. generate-borgmatic-config --destination temp.yaml
  8. cat temp.yaml | sed -e 's/# \S.*$//' | sed -e 's/#//' > temp.yaml.uncommented
  9. mv temp.yaml.uncommented temp.yaml
  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 list info; do
  15. echo "********** borg $sub_command **********"
  16. for line in $(borgmatic --config temp.yaml $sub_command -v 2 2>&1 | grep "borg\w* $sub_command") ; do
  17. echo "$line" | grep '^-' >> borgmatic_borg_flags
  18. done
  19. sort borgmatic_borg_flags > borgmatic_borg_flags.sorted
  20. mv borgmatic_borg_flags.sorted borgmatic_borg_flags
  21. for word in $(borg $sub_command --help | grep '^ -') ; do
  22. # Exclude a bunch of flags that borgmatic actually supports, but don't get exercised by the
  23. # generated sample config, and also flags that don't make sense to support.
  24. echo "$word" | grep ^-- | sed -e 's/,$//' \
  25. | grep -v '^--archives-only$' \
  26. | grep -v '^--critical$' \
  27. | grep -v '^--debug$' \
  28. | grep -v '^--dry-run$' \
  29. | grep -v '^--error$' \
  30. | grep -v '^--help$' \
  31. | grep -v '^--info$' \
  32. | grep -v '^--json$' \
  33. | grep -v '^--keep-last$' \
  34. | grep -v '^--list$' \
  35. | grep -v '^--bsdflags$' \
  36. | grep -v '^--pattern$' \
  37. | grep -v '^--progress$' \
  38. | grep -v '^--stats$' \
  39. | grep -v '^--read-special$' \
  40. | grep -v '^--repository-only$' \
  41. | grep -v '^--show-rc$' \
  42. | grep -v '^--stats$' \
  43. | grep -v '^--verbose$' \
  44. | grep -v '^--warning$' \
  45. | grep -v '^--exclude' \
  46. | grep -v '^--exclude-from' \
  47. | grep -v '^--first' \
  48. | grep -v '^--format' \
  49. | grep -v '^--glob-archives' \
  50. | grep -v '^--match-archives' \
  51. | grep -v '^--last' \
  52. | grep -v '^--format' \
  53. | grep -v '^--patterns-from' \
  54. | grep -v '^--prefix' \
  55. | grep -v '^--short' \
  56. | grep -v '^--sort-by' \
  57. | grep -v '^-h$' \
  58. >> all_borg_flags
  59. done
  60. sort all_borg_flags > all_borg_flags.sorted
  61. mv all_borg_flags.sorted all_borg_flags
  62. comm -13 borgmatic_borg_flags all_borg_flags
  63. rm ./*_borg_flags
  64. done
  65. rm temp.yaml