Restore fails when including S3 uploads

I am using S3 successfully for both file uploads and backups. But restore will only succeed if I exclude uploads in the backup via “Yes (do not include uploads)”. If I just choose Yes when backing up and include uploads then I get an error in the log:

EXCEPTION: Some uploads could not be migrated to the new scheme. You need to fix this manually.
[2022-08-18 20:57:23] /var/www/discourse/lib/file_store/to_s3_migration.rb:156:in `migrate_to_s3’

I’d like the backups to be entirely self-contained and include uploads so I can restore everything from a backup in case I need to migrate everything to another AWS account, some unforeseen disaster or some such event in the future.