Restore from backup fails due to S3 migration

I tried to migrate my discourse instance to a new server, and restore via UI and CLI fail during restore operation. It has to do with S3 migration.

I also had these settings enabled in rails console

SiteSetting.migrate_to_new_scheme = true

The relevant log from the failure was:

Remapping '//' to '/uploads/default/'
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
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...
Restore done.
1 Like

There is a similar report of you search. I think the solution was to turn off S3 uploads when you restore?

Thanks @pfaffman Let me try that.

Do you know of any command line (rails console) way to disable s3 upload?

The Uploads to S3 was disabled during the restore. It still failed.

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.


Thank you!. Yes, I disabled upload to S3 before taking the backup, and then the restore was successful.

1 Like


What to do if a backup was made while it was enabled :slight_smile:

I solved;

I open dump.sql with EmEditor program and search enable_s3_uploads, S3 and all “t” to “f” all “true” to “false”.

Restore successful :slight_smile:


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. :wink:

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.


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.