We’ve been building, testing and intentionally finding gaps in our Discourse forum before we push it entire thing to production. I just migrated my test forum that had S3 uploads enabled from one server to another and upon restoration all of the URLs for anything attached got rewritten to the forum’s URL and not the S3…
Fortunately this is a test forum so we don’t really care too much about the data, however I’d like to:
A. Still fix this.
B. Find a way to mitigate/prevent this from happening in prod.
It wasn’t just posts but it was all images/media/content/avatars(which is pretty dramatic) that got affected by this…
Before restoring you can configure S3 on the destination site in your app.yml (not via the admin dashboard), once you confirm that’s setup and can reach the correct bucket you can go ahead with the restore and media should be linked up correctly.
We effectively did that and that’s how we ended up in that situation.
I copied the app.yml as it was to the destination and then backed up from the original. It was the restoration that was the problem as when we restored, that’s when the URLs got rewritten despite the fact that nothing had changed and we still had S3 uploads enabled.
We did eventually resolve this with a rebake(we think, Discourse’s caching is very brutal so between the many solutions we tried, we don’t actually know what did it), however the questions remain unanswered as to how we do migrations with minimal issues or even restoring from a back up if we have to on prod.
That sounds like you did configure S3 via site settings, not env variables as Kris suggested. The restore process needs to know about S3. That’s not possible with site settings.
You could also create a backup without uploads on the console of you want: discourse backup --sql_only
Restoring such a backup won’t rewrite upload URLs. So, as long as your new server has access to the same S3 bucket, this works.
The S3 configuration is in the app.yml. Not site settings.
Edit:
I realize I’m not being overly explanative and I’m not meaning to hide details.
We use OVH S3 and it’s configured in app.yml.
I backed up our test forum without uploads but still had S3 enabled at that point.
I then restored it on the new site with the exact same app.yml and that’s where the problem started. To be clear it’s fixed right now, but I’m unsure if it was me rebaking it several times or discourse caching aggressively. Which is why I need to know how to really do this properly and get it right first time. My fear is that if I ever need to restore a back up to our production instance and we run into this, I need to know exactly how to fix this asap before users notice.