find-unsupported-borg-options 2.0 KB

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