The backup has many directory and subdirectory. I think you have to copy the files in directories, from both the buckets recursively to the corresponding location in the local server. For example, all the contents in the directory 1X and 2X of both the bucket has to be copied to 1X and 2X directory in the local server. I am not sure about it, but I think so.
Can you confirm that you have properly copied all the files?
Yes, I fully understand and have ensured that their relative paths remain exactly same.
E.g. if a file earlier existed at: //bucket1/uploads/original/2x/f/filename.jpg
And the other //bucket2/uploads/original/1x/a/filename.png
The two now also exist at: /var/discourse/shared/web_only/uploads/default/original/2x/filename.jpg and …/original/1x/a/filename.png
Problems
Before copying the bucket contents to local server, I find that some of my images only show as icons, and full image can be viewed by website visitor by only clicking that icon.
And after I copied (not moved) all the bucket contents to my local server’s above said location, (with relative paths intact), and commanded discourse remap:oldurl-or-path new-url-or-path,
Then nothing changed visibly on the site. But then I commanded rake posts:rebake ,
Then even my image icons disappeared and no url/path showed when I hovered my mouse pointer over the image place holder’s empty place.
You have to give the correct path when remapping, else it may break. I have manually remapped one on the S3 link from the sample output you provided earlier and it works.
You can check 1 sample post of my website here, (the post is in Hindi though, but you may easily find the small icon of the image in between the post). The full image only shows if one clicks on the small icon.
But If I remap, and then rebake, then this icon too disappears completely. And there is no way left for the visitor to see the image.
It seems like you have previously used CloudFront for caching. Clear your browser cache and try again.
If you have made any CloudFront configuration, I think it better to undo all those configurations.
Now, I am also getting the same CloudFront links. It seems like you have enabled AWS CloudFront for your site. Cloudfront is caching the images in your bucket. I think you have to remove the distribution from CloudFront. You have to login into your AWS account to see if CloudFront distribution is active?
I never used CloudFront (or any other CDN) in Aws or in front end. Though around 2 years back, I used CloudFlare for a month or so, but then removed that for good.
Nor did I chose cloudfront in Aws. So no question arises there also.
Moreover, on my PC, when I open the images, they show the aws bucket addresses, not any other CDN.
You’re only suggesting that I remap the image paths (from S3 bucket url to local server path). And then rebake.
But as I told above, I’ve already done that and have found that it compounds the problem. (moreover, after rabking, the ‘Restore’ also doesn’t work and its hard to revert).
I’ll try again, with as much care as possible.
But I was searching for some method with which I could find what’s going behind the curtains. At least with 1 sample post, I wanted to see, which posts are having which bucket mapped and what mess I’m in.
Anyway, I’ll try again and let it know here. Thanks once again.
The path you have specified in your previous remap will be reflected in the output of the below command. Since both buckets are still there, I think your previous remap may be failed. Anyways, it’s up to you now. I hope you will get your solution soon. Best of luck.
./launcher enter app
rails c
Upload.all.sample(2000).pluck(:url)
Switch off S3 uploads in the settings (or in your app.yml if you set it up that way). If you have been using a CDN, then remove the link to it from the setting too (otherwise it doesn’t actually turn off).
Turn off your container. I did this by moving the content to a new container as a backup as an initial step.
Whew! Done. So far I haven’t encountered any issues. Go and test it out!
Nice work! I believe those are the steps that eventually helped me to succeed, but I had done alot of different remaps that didn’t work as well! Great to have formalized instructions.