# 1 van 16551 uploads zijn niet gemigreerd naar S3. S3-migratie mislukt voor db 'default'

**URL:** https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772
**Category:** Self-hosting
**Tags:** cdn, s3
**Created:** [21 februari 2023 om 11:56 UTC](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772 "2023-02-21T11:56:04Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![pawelorzech](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pawelorzech/32/251878_2.png) [@pawelorzech](https://meta.discourse.org/u/pawelorzech)
#### Post date: [21 februari 2023 om 11:56 UTC](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772/1 "2023-02-21T11:56:04Z")

</div>

Hi there,

I’m trying to migrate to S3, but my migrate\_to\_s3 fails.

```plaintext
Updating the URLs in the database...
Removing old optimized images...
Flagging all posts containing lightboxes for rebake...
9756 posts were flagged for a rebake
1 of 16545 uploads are not migrated to S3. S3 migration failed for db 'default'.

```

Here’s output from _rake posts:missing\_uploads_

```plaintext
Looking for missing uploads on: default

10 post uploads are missing.

10 uploads are missing.
9 of 108619 posts are affected.

```

Next I did enter rails console, checked all the posts with the missing uploads (all were .mp4 btw) and deleted them.

And then after trying - once again - to do the migration:

```plaintext

Updating the URLs in the database...
Removing old optimized images...
Flagging all posts containing lightboxes for rebake...
5178 posts were flagged for a rebake
rake aborted!
FileStore::ToS3MigrationError: 1 of 16551 uploads are not migrated to S3. S3 migration failed for db 'default'.
/var/www/discourse/lib/file_store/to_s3_migration.rb:138:in `raise_or_log'
/var/www/discourse/lib/file_store/to_s3_migration.rb:79:in `migration_successful?'
/var/www/discourse/lib/file_store/to_s3_migration.rb:389:in `migrate_to_s3'
/var/www/discourse/lib/file_store/to_s3_migration.rb:65:in `migrate'
/var/www/discourse/lib/tasks/uploads.rake:127:in `migrate_to_s3'
/var/www/discourse/lib/tasks/uploads.rake:106:in `block in migrate_to_s3_all_sites'
/var/www/discourse/vendor/bundle/ruby/3.1.0/gems/rails_multisite-4.0.1/lib/rails_multisite/connection_management.rb:80:in `with_connection'
/var/www/discourse/vendor/bundle/ruby/3.1.0/gems/rails_multisite-4.0.1/lib/rails_multisite/connection_management.rb:90:in `each_connection'
/var/www/discourse/lib/tasks/uploads.rake:104:in `migrate_to_s3_all_sites'
/var/www/discourse/lib/tasks/uploads.rake:100:in `block in <main>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Tasks: TOP => uploads:migrate_to_s3
(See full trace by running task with --trace)

```

---

<div class="post-metadata">

### Author: ![pawelorzech](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pawelorzech/32/251878_2.png) [@pawelorzech](https://meta.discourse.org/u/pawelorzech)
#### Post date: [21 februari 2023 om 17:54 UTC](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772/3 "2023-02-21T17:54:43Z")

</div>

So after all of this, turned off and on again and unfortunately:

```plaintext
Updating the URLs in the database...
Removing old optimized images...
Flagging all posts containing lightboxes for rebake...
5493 posts were flagged for a rebake
1 of 16551 uploads are not migrated to S3. S3 migration failed for db 'default'.

```

What can I do with it now?

---

<div class="post-metadata">

### Author: ![Timelord](https://avatars.discourse-cdn.com/v4/letter/t/ba9def/32.png) [@Timelord](https://meta.discourse.org/u/Timelord)
#### Post date: [21 februari 2023 om 18:08 UTC](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772/4 "2023-02-21T18:08:22Z")

</div>

> [@pawelorzech](#):
>
> `See full trace by running task with --trace)`

Did you try running it again, with the above command?

---

<div class="post-metadata">

### Author: ![pawelorzech](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pawelorzech/32/251878_2.png) [@pawelorzech](https://meta.discourse.org/u/pawelorzech)
#### Post date: [21 februari 2023 om 18:08 UTC](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772/5 "2023-02-21T18:08:56Z")

</div>

Yep, let me do it once again. I’m gonna paste here updated log after it does the thing.

```plaintext
Updating the URLs in the database...
Removing old optimized images...
Flagging all posts containing lightboxes for rebake...
5672 posts were flagged for a rebake
rake aborted!
FileStore::ToS3MigrationError: 1 of 16551 uploads are not migrated to S3. S3 migration failed for db 'default'.
/var/www/discourse/lib/file_store/to_s3_migration.rb:138:in `raise_or_log'
/var/www/discourse/lib/file_store/to_s3_migration.rb:79:in `migration_successful?'
/var/www/discourse/lib/file_store/to_s3_migration.rb:389:in `migrate_to_s3'
/var/www/discourse/lib/file_store/to_s3_migration.rb:65:in `migrate'
/var/www/discourse/lib/tasks/uploads.rake:127:in `migrate_to_s3'
/var/www/discourse/lib/tasks/uploads.rake:106:in `block in migrate_to_s3_all_sites'
/var/www/discourse/vendor/bundle/ruby/3.1.0/gems/rails_multisite-4.0.1/lib/rails_multisite/connection_management.rb:80:in `with_connection'
/var/www/discourse/vendor/bundle/ruby/3.1.0/gems/rails_multisite-4.0.1/lib/rails_multisite/connection_management.rb:90:in `each_connection'
/var/www/discourse/lib/tasks/uploads.rake:104:in `migrate_to_s3_all_sites'
/var/www/discourse/lib/tasks/uploads.rake:100:in `block in <main>'
/var/www/discourse/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/var/www/discourse/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/var/www/discourse/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/var/www/discourse/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/var/www/discourse/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/var/www/discourse/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/var/www/discourse/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/var/www/discourse/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/var/www/discourse/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/var/www/discourse/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/var/www/discourse/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/var/www/discourse/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/var/www/discourse/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/var/www/discourse/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:83:in `block in run'
/var/www/discourse/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/var/www/discourse/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:80:in `run'
bin/rake:13:in `<top (required)>'
/usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.4.4/lib/bundler/cli/exec.rb:58:in `load'
/usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.4.4/lib/bundler/cli/exec.rb:58:in `kernel_load'
/usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.4.4/lib/bundler/cli/exec.rb:23:in `run'
/usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.4.4/lib/bundler/cli.rb:491:in `exec'
/usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.4.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.4.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.4.4/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.4.4/lib/bundler/cli.rb:34:in `dispatch'
/usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.4.4/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.4.4/lib/bundler/cli.rb:28:in `start'
/usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.4.4/exe/bundle:45:in `block in <top (required)>'
/usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.4.4/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.4.4/exe/bundle:33:in `<top (required)>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Tasks: TOP => uploads:migrate_to_s3

```

CC @Timelord

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [21 februari 2023 om 18:40 UTC](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772/6 "2023-02-21T18:40:54Z")

</div>

Unless that 1 upload is absolutely critical, here is your solution:

> [@Migrate\_to\_s3 fails](https://meta.discourse.org/t/migrate-to-s3-fails/209499/15):
>
> You can first try to run it with: SKIP\_FAILED=1 rake uploads:migrate\_to\_s3. If that doesn’t work edit this line here and try again

---

<div class="post-metadata">

### Author: ![pawelorzech](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pawelorzech/32/251878_2.png) [@pawelorzech](https://meta.discourse.org/u/pawelorzech)
#### Post date: [21 februari 2023 om 18:41 UTC](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772/7 "2023-02-21T18:41:43Z")

</div>

Unfortunately I did try it with skip one and then it failed in the similar way. Could try again and get that error log.

That upload is definitely not critical, in any case

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [21 februari 2023 om 18:43 UTC](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772/8 "2023-02-21T18:43:25Z")

</div>

Just edit your local copy of migrator as suggested in the topic. The value needs to be changed from 0 to 1 (since you have just one failing) this would fool the migrator into completion except for the one problem upload.

---

<div class="post-metadata">

### Author: ![pawelorzech](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pawelorzech/32/251878_2.png) [@pawelorzech](https://meta.discourse.org/u/pawelorzech)
#### Post date: [21 februari 2023 om 18:46 UTC](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772/9 "2023-02-21T18:46:48Z")

</div>

```plaintext
root@vps-9d50af6e:/var/discourse# ./launcher enter app
x86_64 arch detected.
root@vps-9d50af6e-app:/var/www/discourse# sed -i '85s/0/100/' lib/file_store/to_s3_migration.rb
root@vps-9d50af6e-app:/var/www/discourse# sed -i '77s/0/100/' lib/file_store/to_s3_migration.rb
root@vps-9d50af6e-app:/var/www/discourse# SKIP_FAILED=1 rake uploads:migrate_to_s3
Please note that migrating to S3 is currently not reversible! 
[CTRL+c] to cancel, [ENTER] to continue

Migrating uploads to S3 for 'default'...

```

```plaintext
...........................................
Updating the URLs in the database...
Removing old optimized images...
Flagging all posts containing lightboxes for rebake...
5953 posts were flagged for a rebake
1 of 16552 uploads are not migrated to S3. S3 migration failed for db 'default'.
root@vps-9d50af6e-app:/var/www/discourse# 

```

Even though - as you see before - I’ve “sed -i” these two lines in to\_s3\_migration.rb

---

<div class="post-metadata">

### Author: ![pawelorzech](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pawelorzech/32/251878_2.png) [@pawelorzech](https://meta.discourse.org/u/pawelorzech)
#### Post date: [22 februari 2023 om 08:11 UTC](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772/11 "2023-02-22T08:11:49Z")

</div>

So why doesn’t the skip-failed work? What could I try next? How to check what wasn’t uploaded? Could this be because of some plugins?

---

<div class="post-metadata">

### Author: ![pawelorzech](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pawelorzech/32/251878_2.png) [@pawelorzech](https://meta.discourse.org/u/pawelorzech)
#### Post date: [22 februari 2023 om 23:30 UTC](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772/12 "2023-02-22T23:30:27Z")

</div>

Bumping, maybe someone else is going to see it and - hopefully - come up with an idea what could work

---

<div class="post-metadata">

### Author: ![pawelorzech](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pawelorzech/32/251878_2.png) [@pawelorzech](https://meta.discourse.org/u/pawelorzech)
#### Post date: [23 februari 2023 om 12:49 UTC](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772/13 "2023-02-23T12:49:01Z")

</div>

I’m gonna add - what I think is an answer - but it doesn’t work great. It is something I’m gonna try in the future though:

1. Doing fresh installation with S3 + CDN, out of the box,
2. Moving all of the uploads from current server to S3,
3. Restoring from backup from old server,
4. Changing app.yml to newer one (that works with S3 + CDN).

So basically I’m gonna try and trick discourse to thing that everything was in the cloud all the way. But it’s not elegant solution to have to reinstall Discourse just because migrate\_to\_s3 fails miserably.

Also it should let me make a decision - do I need that X of Y uploads in s3? Because in that case (and when I was trying to find an answer to my question - in other cases I found) I’d happily get rid of that upload and move on.

---

<div class="post-metadata">

### Author: ![pawelorzech](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pawelorzech/32/251878_2.png) [@pawelorzech](https://meta.discourse.org/u/pawelorzech)
#### Post date: [26 februari 2023 om 15:36 UTC](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772/14 "2023-02-26T15:36:12Z")

</div>

Additional comment to this issue: every time when migrate\_to\_s3 fails, it doesn’t fail with uploading REST of the images. This could (and did) use lots and lots of data because with each failed migration it has put 99% of my data in S3.

And then because of migrate\_to\_s3 being irreversible, I have files on my own HDD and S3, at the same time. Because I can’t get rid of data on HDD. It’s still linked to posts. And I can’t go back to old structure, because it’s irreversible. And can’t put anything between like CDN, because - not everything is on S3.

---

<div class="post-metadata">

### Author: ![pawelorzech](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pawelorzech/32/251878_2.png) [@pawelorzech](https://meta.discourse.org/u/pawelorzech)
#### Post date: [25 maart 2023 om 22:41 UTC](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772/15 "2023-03-25T22:41:11Z")

</div>

Bumping after nearly a month - still haven’t figured it out, maybe now somebody will know something that could help

---

<div class="post-metadata">

### Author: ![pawelorzech](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pawelorzech/32/251878_2.png) [@pawelorzech](https://meta.discourse.org/u/pawelorzech)
#### Post date: [7 mei 2023 om 01:16 UTC](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772/16 "2023-05-07T01:16:56Z")

</div>

Today I tried once again - did fresh installation, then restored from backup. Same errors everywhere. There’s no way to see what 1 media is missing, this `1 of 16545 uploads are not migrated to S3. S3 migration failed for db 'default'.` is going to haunt me.

Bumping this thread, maybe someone could help out…

Some more information. This happens on Discourse (on Docker):

```plaintext
root@forum-app:/var/www/discourse# rake uploads:missing
--------------------------------------------------------------------------------
WARNING! WARNING! WARNING!
--------------------------------------------------------------------------------

default has uploads on S3!
validating without inventory is likely to take an enormous amount of time.
We recommend you run SKIP_EXTERNAL=1 rake uploads:missing to skip validating if on a multisite.
rake aborted!
PG::SyntaxError: ERROR: syntax error at end of input
LINE 1: INSERT INTO verified_ids VALUES
                                        ^
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rack-mini-profiler-3.1.0/lib/patches/db/pg.rb:56:in `exec'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rack-mini-profiler-3.1.0/lib/patches/db/pg.rb:56:in `exec'
/var/www/discourse/lib/file_store/s3_store.rb:423:in `list_missing'
/var/www/discourse/lib/file_store/s3_store.rb:303:in `list_missing_uploads'
/var/www/discourse/lib/tasks/uploads.rake:277:in `list_missing_uploads'
/var/www/discourse/lib/tasks/uploads.rake:270:in `block (2 levels) in <main>'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rails_multisite-4.0.1/lib/rails_multisite/connection_management.rb:80:in `with_connection'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rails_multisite-4.0.1/lib/rails_multisite/connection_management.rb:90:in `each_connection'
/var/www/discourse/lib/tasks/uploads.rake:255:in `block in <main>'
/var/www/discourse/lib/tasks/uploads.rake:281:in `block in <main>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Tasks: TOP => uploads:missing_files
(See full trace by running task with --trace)

```

and

```plaintext
root@forum-app:/var/www/discourse# rake uploads:missing_files
--------------------------------------------------------------------------------
WARNING! WARNING! WARNING!
--------------------------------------------------------------------------------

default has uploads on S3!
validating without inventory is likely to take an enormous amount of time.
We recommend you run SKIP_EXTERNAL=1 rake uploads:missing to skip validating if on a multisite.
rake aborted!
PG::SyntaxError: ERROR: syntax error at end of input
LINE 1: INSERT INTO verified_ids VALUES
                                        ^
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rack-mini-profiler-3.1.0/lib/patches/db/pg.rb:56:in `exec'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rack-mini-profiler-3.1.0/lib/patches/db/pg.rb:56:in `exec'
/var/www/discourse/lib/file_store/s3_store.rb:423:in `list_missing'
/var/www/discourse/lib/file_store/s3_store.rb:303:in `list_missing_uploads'
/var/www/discourse/lib/tasks/uploads.rake:277:in `list_missing_uploads'
/var/www/discourse/lib/tasks/uploads.rake:270:in `block (2 levels) in <main>'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rails_multisite-4.0.1/lib/rails_multisite/connection_management.rb:80:in `with_connection'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rails_multisite-4.0.1/lib/rails_multisite/connection_management.rb:90:in `each_connection'
/var/www/discourse/lib/tasks/uploads.rake:255:in `block in <main>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Tasks: TOP => uploads:missing_files
(See full trace by running task with --trace)

```

then:

```plaintext
root@forum-app:/var/www/discourse# rake posts:missing_uploads
Looking for missing uploads on: default

0 post uploads are missing.

root@forum-app:/var/www/discourse#

```

And - the main star - _rake uploads:migrate\_to\_s3 --trace_

```plaintext
root@forum-app:/var/www/discourse# rake uploads:migrate_to_s3 --trace
** Invoke uploads:migrate_to_s3 (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute uploads:migrate_to_s3
Please note that migrating to S3 is currently not reversible!
[CTRL+c] to cancel, [ENTER] to continue

Migrating uploads to S3 for 'default'...
Uploading files to S3...
 - Listing local files
 => 3 files
 - Listing S3 files
................... => 18784 files
 - Syncing files to S3
...
Updating the URLs in the database...
Removing old optimized images...
Flagging all posts containing lightboxes for rebake...
10116 posts were flagged for a rebake
rake aborted!
FileStore::ToS3MigrationError: 1 of 17210 uploads are not migrated to S3. S3 migration failed for db 'default'.
/var/www/discourse/lib/file_store/to_s3_migration.rb:138:in `raise_or_log'
/var/www/discourse/lib/file_store/to_s3_migration.rb:79:in `migration_successful?'
/var/www/discourse/lib/file_store/to_s3_migration.rb:389:in `migrate_to_s3'
/var/www/discourse/lib/file_store/to_s3_migration.rb:65:in `migrate'
/var/www/discourse/lib/tasks/uploads.rake:127:in `migrate_to_s3'
/var/www/discourse/lib/tasks/uploads.rake:106:in `block in migrate_to_s3_all_sites'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rails_multisite-4.0.1/lib/rails_multisite/connection_management.rb:80:in `with_connection'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rails_multisite-4.0.1/lib/rails_multisite/connection_management.rb:90:in `each_connection'
/var/www/discourse/lib/tasks/uploads.rake:104:in `migrate_to_s3_all_sites'
/var/www/discourse/lib/tasks/uploads.rake:100:in `block in <main>'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:83:in `block in run'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:80:in `run'
bin/rake:13:in `<top (required)>'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.4/lib/bundler/cli/exec.rb:58:in `load'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.4/lib/bundler/cli/exec.rb:58:in `kernel_load'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.4/lib/bundler/cli/exec.rb:23:in `run'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.4/lib/bundler/cli.rb:491:in `exec'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.4/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.4/lib/bundler/cli.rb:34:in `dispatch'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.4/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.4/lib/bundler/cli.rb:28:in `start'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.4/exe/bundle:45:in `block in <top (required)>'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.4/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.4/exe/bundle:33:in `<top (required)>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Tasks: TOP => uploads:migrate_to_s3
root@forum-app:/var/www/discourse#

```

---

<div class="post-metadata">

### Author: ![pawelorzech](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pawelorzech/32/251878_2.png) [@pawelorzech](https://meta.discourse.org/u/pawelorzech)
#### Post date: [8 juni 2023 om 20:08 UTC](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772/17 "2023-06-08T20:08:27Z")

</div>

I think I can bump it once a month, maybe someone would see it. Still doesn’t work!

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [8 juni 2023 om 20:16 UTC](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772/18 "2023-06-08T20:16:35Z")

</div>

I’m not entirely sure if this is a bug or not, but I’ve slipped it into #installation to see if that gets more eyes on it 👀 👍

---

<div class="post-metadata">

### Author: ![pawelorzech](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pawelorzech/32/251878_2.png) [@pawelorzech](https://meta.discourse.org/u/pawelorzech)
#### Post date: [6 juli 2023 om 10:44 UTC](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772/19 "2023-07-06T10:44:19Z")

</div>

Another one:)!

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [6 juli 2023 om 11:24 UTC](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772/20 "2023-07-06T11:24:37Z")

</div>

This is not my area of expertise \[1\] but I saw this the other day which may be useful?

`VERBOSE=1 rake posts:missing_uploads` which I think lists the troublesome posts.

And and also `GIVE_UP=1 VERBOSE=1 rake posts:missing_uploads`, which I think clears out the missing upload flags (but won’t fix the missing uploads).

Not sure if that’s useful, but thought I’d share. 🙂

And it seems we’re cakeday buddies. Happy Cakeday. 🙂

* * *

1. That still remains elusive 🙂

---

<div class="post-metadata">

### Author: ![pawelorzech](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pawelorzech/32/251878_2.png) [@pawelorzech](https://meta.discourse.org/u/pawelorzech)
#### Post date: [10 juli 2023 om 19:17 UTC](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772/23 "2023-07-10T19:17:41Z")

</div>

![Screenshot GW3D6UcV from Warp -- 2023-07-10 at 20.58.43@2x](https://global.discourse-cdn.com/meta/original/4X/c/c/3/cc3577caf8c217cc021652e551bca1243cc84540.png)

Unfortunately no cigar there as well. I think it might have to do something with non-standard files extensions being uploaded discourse. Because (unfortunately I don’t remember how) I’ve checked files that weren’t uploaded once and all they were .mp4 files (which I’ve deleted and still - not sure how I did that, because it probably was back then in Feb).

Just tried upload to s3 once again:

```plaintext
Updating the URLs in the database...
Removing old optimized images...
Flagging all posts containing lightboxes for rebake...
10471 posts were flagged for a rebake
rake aborted!
FileStore::ToS3MigrationError: 1 of 17777 uploads are not migrated to S3. S3 migration failed for db 'default'.
/var/www/discourse/lib/file_store/to_s3_migration.rb:138:in `raise_or_log'
/var/www/discourse/lib/file_store/to_s3_migration.rb:79:in `migration_successful?'
/var/www/discourse/lib/file_store/to_s3_migration.rb:389:in `migrate_to_s3'
/var/www/discourse/lib/file_store/to_s3_migration.rb:65:in `migrate'
/var/www/discourse/lib/tasks/uploads.rake:127:in `migrate_to_s3'
/var/www/discourse/lib/tasks/uploads.rake:106:in `block in migrate_to_s3_all_sites'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rails_multisite-5.0.0/lib/rails_multisite/connection_management.rb:82:in `with_connection'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rails_multisite-5.0.0/lib/rails_multisite/connection_management.rb:92:in `each_connection'
/var/www/discourse/lib/tasks/uploads.rake:104:in `migrate_to_s3_all_sites'
/var/www/discourse/lib/tasks/uploads.rake:100:in `block in <main>'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:83:in `block in run'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:80:in `run'
bin/rake:13:in `<top (required)>'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:58:in `load'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:58:in `kernel_load'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:23:in `run'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:492:in `exec'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:34:in `dispatch'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:28:in `start'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/exe/bundle:45:in `block in <top (required)>'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/exe/bundle:33:in `<top (required)>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Tasks: TOP => uploads:migrate_to_s3

```

Bummer!

---

<div class="post-metadata">

### Author: ![pawelorzech](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pawelorzech/32/251878_2.png) [@pawelorzech](https://meta.discourse.org/u/pawelorzech)
#### Post date: [10 juli 2023 om 21:41 UTC](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772/24 "2023-07-10T21:41:45Z")

</div>

I’ve also just moved this into new server, but because of restoring from this - apparently - broken backup, it failed with this one upload file. I have NO IDEA how I should find what is causing this issues…

New log:

```plaintext
root@forum-app:/var/www/discourse# rake uploads:migrate_to_s3 --trace
** Invoke uploads:migrate_to_s3 (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute uploads:migrate_to_s3
Please note that migrating to S3 is currently not reversible!
[CTRL+c] to cancel, [ENTER] to continue

Migrating uploads to S3 for 'default'...
Uploading files to S3...
 - Listing local files
find: ‘uploads/default/original’: No such file or directory
 => 0 files
 - Listing S3 files
.................... => 19385 files
 - Syncing files to S3

Updating the URLs in the database...
Removing old optimized images...
Flagging all posts containing lightboxes for rebake...
10471 posts were flagged for a rebake
rake aborted!
FileStore::ToS3MigrationError: 1 of 17780 uploads are not migrated to S3. S3 migration failed for db 'default'.
/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/tasks/uploads.rake:126:in `migrate_to_s3'
/var/www/discourse/lib/tasks/uploads.rake:106:in `block in migrate_to_s3_all_sites'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rails_multisite-5.0.0/lib/rails_multisite/connection_management.rb:82:in `with_connection'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rails_multisite-5.0.0/lib/rails_multisite/connection_management.rb:92:in `each_connection'
/var/www/discourse/lib/tasks/uploads.rake:104:in `migrate_to_s3_all_sites'
/var/www/discourse/lib/tasks/uploads.rake:100:in `block in <main>'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:83:in `block in run'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:80:in `run'
bin/rake:13:in `<top (required)>'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:58:in `load'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:58:in `kernel_load'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:23:in `run'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:492:in `exec'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:34:in `dispatch'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:28:in `start'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/exe/bundle:45:in `block in <top (required)>'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.4.13/exe/bundle:33:in `<top (required)>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Tasks: TOP => uploads:migrate_to_s3

```

[Volgende pagina](https://meta.discourse.org/t/1-of-16551-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/255772.md?page=2)
