The discussion revolves around restoring uploads after a backup. eextra asks how to regenerate optimized images and mentions that rebaking posts didn’t help. gerhard provides a solution involving the Rails console: truncating the optimized_images table, ensuring site icons are optimized, enqueuing avatar thumbnails for users with uploaded avatars, resetting the baked_version for posts with uploads, and finally running rake posts:rebake_uncooked_posts to regenerate the content.
Then I manually copied only the old images from standalone/uploads/default/original/1X/* into the same folder (on my hosting).
Is there any command that will create images to the optimized folder (there is still no avatars and images in posts)? Is that all i need to regenerate the images ? How to do it correctly ? rebake post does not help and other commands too. I’ll add that S3 bucket was also set up for files
The following should work as long as you didn’t change the hostname.
Enter the rails console:
cd '/var/discourse
./launcher enter app
rails c
Execute the following:
DB.exec("TRUNCATE TABLE optimized_images")
SiteIconManager.ensure_optimized!
User.where("uploaded_avatar_id IS NOT NULL").find_each do |user|
Jobs.enqueue(:create_avatar_thumbnails, upload_id: user.uploaded_avatar_id)
end
DB.exec(<<~SQL)
UPDATE posts
SET baked_version = NULL
WHERE id IN (SELECT post_id FROM post_uploads)
SQL
And then exit the rails console and execute a rake task: