find-unsupported-borg-options 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 '^--repository-only$' \
  34. | grep -v '^--stats$' \
  35. | grep -v '^--verbose$' \
  36. | grep -v '^--warning$' \
  37. | grep -v '^-h$' \
  38. >> all_borg_flags
  39. done
  40. sort all_borg_flags > all_borg_flags.sorted
  41. mv all_borg_flags.sorted all_borg_flags
  42. comm -13 borgmatic_borg_flags all_borg_flags
  43. rm ./*_borg_flags
  44. done
  45. rm temp.yaml