Just following up on this. We had been storing uploaded images on S3 and had not chosen to download remote images to avoid broken links. I’m not sure if this is relevant, but the point is that images should have been stored on S3 and referenced with S3 URLs in Discourse.
After the upgrade, many many images were not showing. Category logos, and uploads by users in posts. Looking in S3, the referenced filenames did not exist.
Luckily, we have S3 versioning enabled and I was able to see in the S3 console that MANY referenced images had been deleted during/after the upgrade.
I adapted a Python script I found (https://stackoverflow.com/a/54613767/2829685) to iterate over all object versions in our S3 bucket and remote “delete markers” from the current version of any file with a last_modified timestamp equal to or greater than the date of the upgrade.
This took most of the day to run and undeleted around 45 thousand images. It looks like Discourse creates many thumbnails for each image.
Now our category logo and user-uploaded images in posts are back. But I have no idea how all these images could have possibly been deleted in S3 as part of the upgrade process.
Seems like this could be a very dangerous bug in the Discourse upgrade process? Although maybe it has already been fixed, as I was upgrading from such an old version.