Restoring a Discourse instance from a backup fails due to S3 migration issues. Senthil reports this issue, and pfaffman suggests disabling S3 uploads during the restore process. However, this doesn’t work in Senthil’s case.
A workaround is to disable the enable_s3_uploads site setting before creating the backup, as suggested by gerhard. This approach works for Senthil.
If a backup was made with S3 uploads enabled, a manual fix is required. MuhYal successfully restored their instance by editing the dump.sql file, replacing all instances of t and true with f and false, respectively. gerhard recommends using a suitable editor, such as SciTE, to handle large files.
Remapping '//thinnal.s3.dualstack.us-east-1.amazonaws.com/' to '/uploads/default/'
incoming_emails=2
optimized_images=3851
post_revisions=86
posts=618
stylesheet_cache=10
topic_links=107
topics=150
uploads=419
user_histories=20
Migrating uploads to S3...
Checking if default already migrated...
1971 of 1977 uploads are not migrated to S3. S3 migration failed for db 'default'.
266 posts are not remapped to new S3 upload URL. S3 migration failed for db 'default'.
Looking for missing uploads on: default
0 post uploads are missing.
No posts require rebaking
Migrating uploads to S3 for 'default'...
Some uploads were not migrated to the new scheme. Please run these commands in the rails console
SiteSetting.migrate_to_new_scheme = true
Jobs::MigrateUploadScheme.new.execute(nil)
Restore process was cancelled!
Trying to rollback...
Rolling back...
Cleaning stuff up...
Dropping function from the discourse_functions schema
Removing tmp '/var/www/discourse/tmp/restores/default/2019-09-02-140750' directory...
Unpausing sidekiq...
Marking restore as finished...
Notifying 'system' of the end of the restore...
Finished!
[FAILED]
Restore done.
That’s a known problem. As a workaround, you could temporarily disable the enable_s3_uploads site setting before creating the backup. You can re-enable on the new server after the restore.
Well, then you’ll have to get your hands dirty. Sorry about that. I’m planning to start refactoring and improving backups and restores next week, but it can take a while until everything’s peachy again.
That’s great! I was going to suggest exactly those steps.
For anyone reading this in the future: If you need to edit the dump.sql (which might be quite large), I suggest Scintilla and SciTE as editor. It handles those large files without problems.