# Uploads migration to S3 fails

**URL:** https://meta.discourse.org/t/uploads-migration-to-s3-fails/106487
**Category:** Support
**Created:** [14 בינואר,‏ 2019,‏ 12:31pm UTC](https://meta.discourse.org/t/uploads-migration-to-s3-fails/106487 "2019-01-14T12:31:38Z")
**Posts on this page:** 7
**Page:** 2

<div class="post-metadata">

### Author: ![Bathinda](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bathinda/32/135888_2.png) [@Bathinda](https://meta.discourse.org/u/Bathinda)
#### Post date: [20 בדצמבר,‏ 2019,‏ 1:16pm UTC](https://meta.discourse.org/t/uploads-migration-to-s3-fails/106487/24 "2019-12-20T13:16:42Z")

</div>

> [@vulkanino](#):
>
> The migration still was not happy until I did:  
> `export DISCOURSE_S3_CDN_URL=""`  
> (though I don’t use a CDN).

Can you pls elaborate what you did here (you showed double inverted commas here).  
And what’s the relevance of this edit? I mean, how did you know that this was the culprit or how did it solve this?

I’m facing with this error while migrating my images/assets from local to S3: “S3 migration failed for db ‘default’” (my branding logos don’t show anywhere).

---

<div class="post-metadata">

### Author: ![eextra](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eextra/32/170266_2.png) [@eextra](https://meta.discourse.org/u/eextra)
#### Post date: [24 במרץ,‏ 2020,‏ 6:04am UTC](https://meta.discourse.org/t/uploads-migration-to-s3-fails/106487/26 "2020-03-24T06:04:32Z")

</div>

```plaintext
> FileStore::ToS3MigrationError: Some uploads could not be migrated to the new scheme. You need to fix this manually.
> /var/www/discourse/lib/file_store/to_s3_migration.rb:151:in `migrate_to_s3'
> /var/www/discourse/lib/file_store/to_s3_migration.rb:61:in `migrate'
> /var/www/discourse/lib/tasks/uploads.rake:239:in `migrate_to_s3'
> /var/www/discourse/lib/tasks/uploads.rake:218:in `block in migrate_to_s3_all_sites'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rails_multisite-2.1.1/lib/rails_multisite/connection_management.rb:64:in `with_connection'
> /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rails_multisite-2.1.1/lib/rails_multisite/connection_management.rb:74:in `each_connection'
> /var/www/discourse/lib/tasks/uploads.rake:216:in `migrate_to_s3_all_sites'
> /var/www/discourse/lib/tasks/uploads.rake:212:in `block in <top (required)>'

```

 ![image](https://global.discourse-cdn.com/meta/original/3X/6/4/649160765b8afd9abe4604d403aa206cadf4776d.png)  
Generally, I have these files. All the files are (I guess) except the **original** folder - there is no pictures  
Why? Maybe it is better to just copy it by hand ctr +C and that’s it … ?

assets folder:

 ![image](https://global.discourse-cdn.com/meta/original/3X/4/7/470a9284bcedf17744534e40ec40ddc803f94e7f.png)

---

<div class="post-metadata">

### Author: ![eextra](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eextra/32/170266_2.png) [@eextra](https://meta.discourse.org/u/eextra)
#### Post date: [24 במרץ,‏ 2020,‏ 6:24am UTC](https://meta.discourse.org/t/uploads-migration-to-s3-fails/106487/27 "2020-03-24T06:24:25Z")

</div>

> [@vulkanino](#):
>
> Then I edited uploads.rake and commented out this block:
> 
> ```plaintext
> if SiteSetting.Upload.s3_cdn_url.blank?
> puts "Please provide the 'DISCOURSE_S3_CDN_URL' environment variable"
> exit 3
> end
> 
> ```

I tried to change it, but it’s no longer at lib/tasks/uploads.rake . So what could be wrong ?

---

<div class="post-metadata">

### Author: ![Bathinda](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bathinda/32/135888_2.png) [@Bathinda](https://meta.discourse.org/u/Bathinda)
#### Post date: [16 באפריל,‏ 2021,‏ 12:57pm UTC](https://meta.discourse.org/t/uploads-migration-to-s3-fails/106487/28 "2021-04-16T12:57:20Z")

</div>

> [@vulkanino](#):
>
> The migration still was not happy until I did:  
> `export DISCOURSE_S3_CDN_URL=""`  
> (though I don’t use a CDN).

Pls tell exactly where to put this line, and whether the double quotes after equal to sign are to be put in as they are (blank), or are we supposed to insert our own S3 CDN Url in side those quotes? Pls guide.

---

<div class="post-metadata">

### Author: ![vulkanino](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vulkanino/32/119654_2.png) [@vulkanino](https://meta.discourse.org/u/vulkanino)
#### Post date: [16 באפריל,‏ 2021,‏ 1:17pm UTC](https://meta.discourse.org/t/uploads-migration-to-s3-fails/106487/29 "2021-04-16T13:17:01Z")

</div>

> [@eextra](#):
>
> uploads.rake

The `export` instruction was issued on the command line  
`export DISCOURSE_S3_CDN_URL=""`

So that linux knows it as a system variable. I had to set that variable with the empty quotes even if I don’t use a CDN.

---

<div class="post-metadata">

### Author: ![Bathinda](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bathinda/32/135888_2.png) [@Bathinda](https://meta.discourse.org/u/Bathinda)
#### Post date: [7 במאי,‏ 2021,‏ 12:26pm UTC](https://meta.discourse.org/t/uploads-migration-to-s3-fails/106487/30 "2021-05-07T12:26:42Z")

</div>

> [@vulkanino](#):
>
> ```plaintext
> if SiteSetting.Upload.s3_cdn_url.blank?
> puts "Please provide the 'DISCOURSE_S3_CDN_URL' environment variable"
> exit 3
> end
> 
> ```

The above said lines no longer exist in the file `lib/tasks/upload.rake`  
I searched the whole (above-said) file very carefully.

> [@vulkanino](#):
>
> The `export` instruction was issued on the command line  
> `export DISCOURSE_S3_CDN_URL=""`

Thanks for the reply, but which command line are you talking? Is this command to be given inside the web\_only container?

---

<div class="post-metadata">

### Author: ![vulkanino](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vulkanino/32/119654_2.png) [@vulkanino](https://meta.discourse.org/u/vulkanino)
#### Post date: [7 במאי,‏ 2021,‏ 1:22pm UTC](https://meta.discourse.org/t/uploads-migration-to-s3-fails/106487/31 "2021-05-07T13:22:40Z")

</div>

They might have updated since then, it was two years ago.

> [@Bathinda](#):
>
> but which command line are you talking?

I meant your Linux server. I “entered” in the container (`sudo ./launcher enter app`), and exported the environment variables so that the system know their values. Hope this helps.

[Previous page](https://meta.discourse.org/t/uploads-migration-to-s3-fails/106487.md?page=1)
