I ended up doing the backup and restore and it worked as expected.
For reference in case anyone else runs into a similar issue…
I ran into a bit of an issue at first as the restore process apparently calls the uploads:migrate_to_s3 internally and it was getting hung up.
2025-02-26 00:24:16] Migrating the database...
[2025-02-26 00:24:24]
[2025-02-26 00:24:24] Reconnecting to the database...
[2025-02-26 00:24:24] Reloading site settings...
[2025-02-26 00:24:24] Disabling outgoing emails for non-staff users...
[2025-02-26 00:24:24] Disabling readonly mode...
[2025-02-26 00:24:24] Clearing category cache...
[2025-02-26 00:24:24] Reloading translations...
[2025-02-26 00:24:24] Remapping uploads...
[2025-02-26 00:24:24] Restoring uploads, this may take a while...
[2025-02-26 00:25:09] EXCEPTION: 12 of 12208 uploads are not migrated to S3. S3 migration failed for db 'default'.
[2025-02-26 00:25:09] /var/www/discourse/lib/file_store/to_s3_migration.rb:132:in `raise_or_log'
/var/www/discourse/lib/file_store/to_s3_migration.rb:73:in `migration_successful?'
/var/www/discourse/lib/file_store/to_s3_migration.rb:383:in `migrate_to_s3'
/var/www/discourse/lib/file_store/to_s3_migration.rb:59:in `migrate'
/var/www/discourse/lib/file_store/s3_store.rb:354:in `copy_from'
/var/www/discourse/lib/backup_restore/uploads_restorer.rb:69:in `restore_uploads'
/var/www/discourse/lib/backup_restore/uploads_restorer.rb:49:in `restore'
/var/www/discourse/lib/backup_restore/restorer.rb:167:in `restore_uploads'
/var/www/discourse/lib/backup_restore/restorer.rb:71:in `run'
/var/www/discourse/script/spawn_backup_restore.rb:20:in `restore'
/var/www/discourse/script/spawn_backup_restore.rb:33:in `block in <main>'
/var/www/discourse/script/spawn_backup_restore.rb:4:in `fork'
/var/www/discourse/script/spawn_backup_restore.rb:4:in `<main>'
[2025-02-26 00:25:09] Trying to rollback...
[2025-02-26 00:25:09] Rolling back...
[2025-02-26 00:25:10] Cleaning stuff up...
I ended up running some SQL queries in the data container to see if I could figure out what was going on.
./launcher enter data
sudo -u postgres psql discourse
SELECT url FROM uploads WHERE url NOT LIKE '%s3%';
That just returned some standard built-in items from Discourse, so I tried the reverse:
SELECT url from uploads where url LIKE '%s3%' limit 10;
That gave me a bunch of matches in the format:
//{my-bucket-name}.s3.dualstack.us-east-2.amazonaws.com/original/2X/5/{image-id}.jpeg
So then I tried a query to get everything except items which matched that s3.dualstack host and I found that there were 12 old entries using a slightly different format (matching the number that failed from prior restore log failure).
//{my-bucket-name}.s3-us-east-2.amazonaws.com/{file-path}.jpeg
When I checked for the existence of those files in the actual bucket, they didn’t exist, so I ended up deleting them with something like:
DELETE FROM uploads where url LIKE '%{my-bucket-name}.s3-us-east-2.amazonaws.com%';
After that, the backup and restore worked as expected!
PS. Don’t forget to re-enable emails after you restore the backup!
/admin/site_settings/category/all_results?filter=disable_email