Attachments uploaded to S3 404 on a new server

AI-generated summary

Eviepayne is troubleshooting an issue where attachments uploaded to S3 return 404 errors after migrating Discourse to a new server. Despite S3 and CDN being configured correctly and most uploads working, certain file types—specifically .funscript files—are not appearing in S3 or local uploads directories (/var/discourse/shared/standalone/uploads). Running rake uploads:analyze_missing_s3 reports zero missing uploads, yet the files are only found in Docker’s temporary download_cache, not persisted or synced to S3. Eviepayne references a meta.discourse.org thread that explains the behavior but notes the issue persists after server redeployment via SQL restore. The core problem is that these attachments are not being saved to S3 during migration or restore, causing broken links post-deploy. The user seeks to understand where these files are stored and how to ensure they’re properly migrated or uploaded to S3.

UPDATE:
I found this
Attachments are not being saved in S3

But when I migrate the server, these are not available, they result in a 404.
See below # New Discovery, I’m leaving the OP just in case it helps.

Original Post

I am working on migrating a server from one place to another.
There is S3 and a CDN configured and most uploads seem to work fine.
In the process of the migration I noticed a specific kind of attachment is not uploaded to S3:

I tried:

root@discourse-app: /var/www/discourse# rake uploads:analyze_missing_s3
List of posts with missing images:
Total missing uploads: 0, newest is 
Total problem posts: 0 with 0 missing uploads
Other missing uploads count: 0

When I go under /var/discourse/shared/standalone/uploads:

root@discourse:/var/discourse/shared/standalone/uploads$ ls -lhAR
total 4.0K
drwxr-xr-x 3 nosferatu www-data 4.0K Jan  8  2024 csv_exports

./csv_exports:
total 4.0K
drwxr-xr-x 2 nosferatu www-data 4.0K Aug 21 00:45 default

./csv_exports/default:
total 0

I can only find:

root@discourse:/var/discourse/shared/standalone/uploads$ locate .funscript                                                                                        
/var/lib/docker/overlay2/3cc16f26278c625a5321f97cdc25e75e82c5a222ac7a9310e0a9ae24386777d8/diff/var/www/discourse/tmp/download_cache/031cb76f4769f63c6733bb3ef78ca520dbb11b89.funscript       
/var/lib/docker/overlay2/3cc16f26278c625a5321f97cdc25e75e82c5a222ac7a9310e0a9ae24386777d8/diff/var/www/discourse/tmp/download_cache/0e7f3157d4b26e7600a04b19d8e49b4f97391f44.funscript
...

When I check the S3 storage, there is no such files by those names.
I have no idea where these files are stored.

New discovery

As mentioned above, I found why the links behave the way they do.
But now when I redeploy a server with the following steps:

  1. Spin up discourse
  2. Restore from sql.gz in Admin > Backups > Restore

When I try to download an attachment, it 404s.