S3 migrations from/to minio problems


(hosna) #1

I recently tried to configure my discourse to use minio according to this topic:

lets say my discourse domain is example.com and my minio endpoint is minio.example.com and my bucket name is test. I faced the following problems

1- Migration from local to minio.

I did this

cd /var/discourse
./launcher enter app
rake uploads:migrate_to_s3
rake posts:rebake

It seems all files are migrated to minio however all links in my forum are broken now. they are like this:

https://example.com//minio.example.com/test/uploads/the-rest-of-url...

instead of

https://minio.example.com/test/uploads/the-rest-of-url...

2- Migration from minio to local.
I did this:

cd /var/discourse
./launcher enter app
rake uploads:migrate_from_s3
rake posts:rebake

And all I can see is only images migrated from minio to local. not any zip or mp4 file.


What does rake uploads:migrate_from_s3 exactly do?
(Rishabh Nambiar) #2

This is indeed a bug and I will look into it this week, the rake tasks were actually never modified for Minio so I’ll start with doing that. As of now, the rake tasks only work with DigitalOcean Spaces and AWS S3.


(hosna) #4

Any chance we get this bug fixed soon?


(Rishabh Nambiar) #5

Hi, I’m working on it right now, is your Minio endpoint running with a domain name? like abc.com


(Alan Tan) #6

This was due to a bug in the uploads:migrate_to_s3 rake task and has been fixed in


(hosna) #7

Yes. My minio endpoint is like m.example.com

Ok Im going to check it soon and will inform if its fixed for me. :blush:

Is this also fixed @tgxworld ?


(hosna) #8

Still it has problem.

now when I do

cd /var/discourse
./launcher enter app
rake uploads:migrate_to_s3
rake posts:rebake

the mp4 video url is turned to

//minio.example.com/test/uploads/the-rest-of-url....mp4

instead of

https://minio.example.com/test/uploads/the-rest-of-url....mp4

(Alan Tan) #9

Did you rebuild before running?


(hosna) #10

I upgraded with web interface. So I thought maybe no rebuild is needed.


(hosna) #11

I also did a rebuild but after it I get same result.

Before migrating to minio:


Link is correct and start with https:// and it shows the video in the post.

After migrating to minio and rebake all posts:


link is correct however it doesn’t start with https:// and as a result, the video doesn’t appear in the post. we can only see the link.

Btw as I guessed correctly, migration from minio to local is still not fixed. :point_down:


(Rishabh Nambiar) #12

I’m not sure what the issue is but have you entered your s3_endpoint as https://m.example.com or just m.example.com in Site Settings?
If this is the problem then we need to improve the help text for that field.


(hosna) #13

I entered it as https://m.example.com. Is it correct? or I should go for m.example.com ? :thinking:


(Rishabh Nambiar) #14

Yes it is. @tgxworld if you are still looking into this, the one thing different about this Minio setup is that the force_path_style setting is true. I don’t see how this can make the https:// go away :thinking:


(hosna) #15

This bug is still not fixed. And It got even worse.

First, I thought maybe I just don’t need to migrate local data and discourse would read them from local disk even If I enable s3 uploads. However, after one day, I realized that my local files, except for images, won’t be loaded (mp3, mp4 etc).

So I decided to migrate the files anyway and then change all strings starting with my minio endpoint by adding https:// , as the problem I mentioned here :

However, migration reports something like
/original/1X/dd758eae1e79c7a2b844d571da9c67ca1df02d39.mp3 does not exist locally
for all files, Although I checked the path and the file exist. (at least this migration was correct two months ago!)

so I desperately disabled s3 and rebaked all post. However, discourse still doesn’t load local files. I still am sure that the file exists there. So now all of my upload links are broken.

@tgxworld did a major update recently to uploads.rake. So maybe those commits broke it.


Setting up backup and image uploads to Minio S3
(Alan Tan) #16

Can you provide me with the output of

./launcher enter app
rails c
Upload.where("url LIKE '%dd758eae1e79c7a2b844d571da9c67ca1df02d39%'").first

(hosna) #17
rails c
Upload.where("url LIKE '%dd758eae1e79c7a2b844d571da9c67ca1df02d39%'").first
[1] pry(main)> Upload.where("url LIKE '%dd758eae1e79c7a2b844d571da9c67ca1df02d39%'").first

=> #<Upload:0x0000563a9e2ff510
 id: 248,
 user_id: 1,
 original_filename: "03 Dishab.mp3",
 filesize: 4674760,
 width: nil,
 height: nil,
 url: "/original/1X/dd758eae1e79c7a2b844d571da9c67ca1df02d39.mp3",
 created_at: Wed, 14 Nov 2018 21:47:40 UTC +00:00,
 updated_at: Wed, 14 Nov 2018 21:47:40 UTC +00:00,
 sha1: "dd758eae1e79c7a2b844d571da9c67ca1df02d39",
 origin: nil,
 retain_hours: nil,
 extension: "mp3",
 thumbnail_width: nil,
 thumbnail_height: nil>
[2] pry(main)> 



(Mittineague) #18

Do you know if that is the only file name with a space in it? It seems if spaces in file names had the potential to cause a problem it would have come up before, but maybe not?


(hosna) #19

I dont think this is the problem. Cause as far as I saw, All files are broken now. Its really rare I would have space in each and every upload.


(Alan Tan) #20

Did you carry out any remaps manually? /original/1X/dd758eae1e79c7a2b844d571da9c67ca1df02d39.mp3 is not a valid URL that we would generate.


(hosna) #21

I don’t know what is a remap. So I think I didn’t do it.

Why? can you explain more? :thinking:
In fact, all of the uploads up until now are in uploads/default/original/1X