It was easier than I initially thought; not sure why this condition was missing initially.
This solution is not ideal; there is still a minor chance for edge cases where logs are uploaded for the previous backup, to be specific, the interval after restore and before uploading new compaction. There are three ways of mitigating this, created a follow-up task: ENG-11340.