find-unsupported-borg-options 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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.
  7. generate-borgmatic-config --destination temp.yaml
  8. # For each sub-command (prune, create, and check), collect the Borg command-line flags that result
  9. # from running borgmatic with the generated configuration. Then, collect the full set of available
  10. # Borg flags as reported by "borg --help" for that sub-command. Finally, compare the two lists of
  11. # flags to determine which Borg flags borgmatic doesn't yet support.
  12. for sub_command in prune create check list info; do
  13. echo "********** borg $sub_command **********"
  14. for line in $(borgmatic --config temp.yaml --$sub_command -v 2 2>&1 | grep "borg\w* $sub_command") ; do
  15. echo "$line" | grep '^-' >> borgmatic_borg_flags
  16. done
  17. sort borgmatic_borg_flags > borgmatic_borg_flags.sorted
  18. mv borgmatic_borg_flags.sorted borgmatic_borg_flags
  19. for word in $(borg $sub_command --help | grep '^ -') ; do
  20. # Exclude a bunch of flags that borgmatic actually supports, but don't get exercised by the
  21. # generated sample config, and also flags that don't make sense to support.
  22. echo "$word" | grep ^-- | sed -e 's/,$//' \
  23. | grep -v '^--archives-only$' \
  24. | grep -v '^--critical$' \
  25. | grep -v '^--debug$' \
  26. | grep -v '^--dry-run$' \
  27. | grep -v '^--error$' \
  28. | grep -v '^--help$' \
  29. | grep -v '^--info$' \
  30. | grep -v '^--list$' \
  31. | grep -v '^--nobsdflags$' \
  32. | grep -v '^--pattern$' \
  33. | grep -v '^--read-special$' \
  34. | grep -v '^--repository-only$' \
  35. | grep -v '^--show-rc$' \
  36. | grep -v '^--stats$' \
  37. | grep -v '^--verbose$' \
  38. | grep -v '^--warning$' \
  39. | grep -v '^-h$' \
  40. >> all_borg_flags
  41. done
  42. sort all_borg_flags > all_borg_flags.sorted
  43. mv all_borg_flags.sorted all_borg_flags
  44. comm -13 borgmatic_borg_flags all_borg_flags
  45. rm ./*_borg_flags
  46. done
  47. rm temp.yaml