# Restore fails due to s3 migration failure

**URL:** <https://meta.discourse.org/t/restore-fails-due-to-s3-migration-failure/409771>\
**Category:** Product Support\
**Created:** [August 11, 2026, 8:19am UTC](https://meta.discourse.org/t/restore-fails-due-to-s3-migration-failure/409771 "2026-08-11T08:19:55Z")\
**Posts on this page:** 4\
**Page:** 1

## AI-generated summary

[marcozambi](/t/-/409771/1) reports that restoring a Discourse backup to a new server fails during the S3 migration phase, despite the posts and categories restoring successfully. The error `rake posts:missing_uploads identified 2274 issues` causes the process to crash rather than providing a manageable list of problematic files. [awesomerobot](/t/-/409771/2) explains that the failure is due to flags from missing uploads carried over in the backup, which the restore process counts as errors. To resolve this, they recommend running `rake posts:missing_uploads` on the **old** server to identify and repair or ignore the missing uploads before taking a fresh backup. [marcozambi](/t/-/409771/3) confirms this solution works, noting that it provided a clear list of issues and a viable path forward.

<div class="post-metadata">

**Author:** ![marcozambi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marcozambi/32/119505_2.png) [@marcozambi](https://meta.discourse.org/u/marcozambi)\
**Post date:** [August 11, 2026, 8:19am UTC](https://meta.discourse.org/t/restore-fails-due-to-s3-migration-failure/409771/1 "2026-08-11T08:19:55Z")

</div>

We host our own Discourse database and we are trying to migrate to a new server.

Both sides (old & new) are updated to the latest Discourse (a rebuild app on both sides was done a few minutes apart) and the migration to the new Postgresql was successfully performed on the old server a few days ago. I would exclude these things as the source of our problems.

All our uploads are stored on an S3-compatible object storage (Digitalocean Spaces), so on paper the migration should be easy. I thought that if the “posts & categories” part of the restore works well, then the links to s3 uploads should just work, right?

Wrong. Whenever I perform the restore of our backup in the new server, the posts part goes 100% well, but then it fails on the s3 part.

This is the error we see.

```plaintext
Reconnecting to the database...
Reloading site settings...
Disabling outgoing emails for non-staff users...
Running seed fu...
Disabling readonly mode...
Clearing category cache...
Reloading translations...
Remapping uploads...
Restoring uploads, this may take a while...
Migrating uploads to S3 for 'default'...
Uploading files to S3...
 - Listing local files
 => 3 files
 - Listing S3 files
..................................................................................................................................................... => 148892 files
 - Syncing files to S3
...
Updating the URLs in the database...
Removing old optimized images...
Flagging all posts containing lightboxes for rebake...
29368 posts were flagged for a rebake
EXCEPTION: rake posts:missing_uploads identified 2274 issues. S3 migration failed for db 'default'.
/var/www/discourse/lib/file_store/to_s3_migration.rb:132:in 'FileStore::ToS3Migration#raise_or_log'
/var/www/discourse/lib/file_store/to_s3_migration.rb:104:in 'FileStore::ToS3Migration#migration_successful?'
/var/www/discourse/lib/file_store/to_s3_migration.rb:384:in 'FileStore::ToS3Migration#migrate_to_s3'
/var/www/discourse/lib/file_store/to_s3_migration.rb:59:in 'FileStore::ToS3Migration#migrate'
/var/www/discourse/lib/file_store/s3_store.rb:372:in 'FileStore::S3Store#copy_from'
/var/www/discourse/lib/backup_restore/uploads_restorer.rb:69:in 'BackupRestore::UploadsRestorer#restore_uploads'
/var/www/discourse/lib/backup_restore/uploads_restorer.rb:49:in 'BackupRestore::UploadsRestorer#restore'
/var/www/discourse/lib/backup_restore/restorer.rb:179:in 'BackupRestore::Restorer#restore_uploads'
/var/www/discourse/lib/backup_restore/restorer.rb:72:in 'BackupRestore::Restorer#run'
script/discourse:242:in 'DiscourseCLI#restore'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/thor-1.5.0/lib/thor/command.rb:28:in 'Thor::Command#run'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/thor-1.5.0/lib/thor/invocation.rb:127:in 'Thor::Invocation#invoke_command'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/thor-1.5.0/lib/thor.rb:538:in 'Thor.dispatch'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/thor-1.5.0/lib/thor/base.rb:585:in 'Thor::Base::ClassMethods#start'
script/discourse:396:in '<top (required)>'
/usr/local/lib/ruby/gems/3.4.0/gems/bundler-4.0.11/lib/bundler/cli/exec.rb:61:in 'Kernel.load'
/usr/local/lib/ruby/gems/3.4.0/gems/bundler-4.0.11/lib/bundler/cli/exec.rb:61:in 'Bundler::CLI::Exec#kernel_load'
/usr/local/lib/ruby/gems/3.4.0/gems/bundler-4.0.11/lib/bundler/cli/exec.rb:24:in 'Bundler::CLI::Exec#run'
/usr/local/lib/ruby/gems/3.4.0/gems/bundler-4.0.11/lib/bundler/cli.rb:504:in 'Bundler::CLI#exec'
/usr/local/lib/ruby/gems/3.4.0/gems/bundler-4.0.11/lib/bundler/vendor/thor/lib/thor/command.rb:28:in 'Bundler::Thor::Command#run'
/usr/local/lib/ruby/gems/3.4.0/gems/bundler-4.0.11/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in 'Bundler::Thor::Invocation#invoke_command'
/usr/local/lib/ruby/gems/3.4.0/gems/bundler-4.0.11/lib/bundler/vendor/thor/lib/thor.rb:538:in 'Bundler::Thor.dispatch'
/usr/local/lib/ruby/gems/3.4.0/gems/bundler-4.0.11/lib/bundler/cli.rb:35:in 'Bundler::CLI.dispatch'
/usr/local/lib/ruby/gems/3.4.0/gems/bundler-4.0.11/lib/bundler/vendor/thor/lib/thor/base.rb:584:in 'Bundler::Thor::Base::ClassMethods#start'
/usr/local/lib/ruby/gems/3.4.0/gems/bundler-4.0.11/lib/bundler/cli.rb:29:in 'Bundler::CLI.start'
/usr/local/lib/ruby/gems/3.4.0/gems/bundler-4.0.11/exe/bundle:28:in 'block in <top (required)>'
/usr/local/lib/ruby/gems/3.4.0/gems/bundler-4.0.11/lib/bundler/friendly_errors.rb:118:in 'Bundler.with_friendly_errors'
/usr/local/lib/ruby/gems/3.4.0/gems/bundler-4.0.11/exe/bundle:20:in '<top (required)>'
/usr/local/bin/bundle:25:in 'Kernel#load'
/usr/local/bin/bundle:25:in '<main>'
Trying to rollback...
Rolling back...
Cleaning stuff up...
Dropping functions from the discourse_functions schema...
Removing tmp '/var/www/discourse/tmp/restores/default/2026-08-11-075958' directory...
Unpausing sidekiq...
Marking restore as finished...
Notifying 'system' of the end of the restore...
Finished!
[FAILED]
Restore done.

```

I have a few questions:

- why is it failing when in principle the set-up for the s3 environment we have saved in the database is unchanged?
- why is it crashing, instead of creating a list of the 2274 issues it found with the uploads that I can manage somehow?
- why is it automatically rolling back to an empty database, leaving me in the middle of nowhere?
- Is there a workaround to let it finish the restore (even if not literally successfully), or at least preventing it from rolling back and let me deal with the issues it found with the uploads?

Thanks a lot in advance for any help!

---

<div class="post-metadata">

**Author:** ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)\
**Post date:** [August 12, 2026, 3:31pm UTC](https://meta.discourse.org/t/restore-fails-due-to-s3-migration-failure/409771/2 "2026-08-12T15:31:18Z")

</div>

> [@marcozambi](#):
>
> - why is it crashing, instead of creating a list of the 2274 issues it found with the uploads that I can manage somehow?

Because it’s just counting flags that came along with the backup. This isn’t the process that actually finds the issues.

Ideally you’d want to clear the missing uploads flags on the old server first, then take a fresh backup.

You can run a task that will list and attempt to repair the missing uploads on the old server (it may take a while)

```bash
cd /var/discourse
./launcher enter app
VERBOSE=1 rake posts:missing_uploads

```

and mark any remaining as ignored if you want to continue

```bash
GIVE_UP=1 VERBOSE=1 rake posts:missing_uploads

```

At that point you can take a new backup and restore it.

---

<div class="post-metadata">

**Author:** ![marcozambi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marcozambi/32/119505_2.png) [@marcozambi](https://meta.discourse.org/u/marcozambi)\
**Post date:** [August 12, 2026, 6:04pm UTC](https://meta.discourse.org/t/restore-fails-due-to-s3-migration-failure/409771/3 "2026-08-12T18:04:13Z")

</div>

Many thanks for this answer! It actually helps a lot because at least I got a full list of all the topics having issues with uploads.

I will try to fix as many as I can but at least now I have a way forward!

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [September 11, 2026, 6:04pm UTC](https://meta.discourse.org/t/restore-fails-due-to-s3-migration-failure/409771/4 "2026-09-11T18:04:51Z")

</div>

Closed on September 11, 2026, 6:04pm UTC

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