# A ordem correta para restaurar uploads?

**URL:** <https://meta.discourse.org/t/the-correct-order-of-restoring-uploads/144582>\
**Category:** Self-hosting\
**Created:** [Março 17, 2020, 1:40pm UTC](https://meta.discourse.org/t/the-correct-order-of-restoring-uploads/144582 "2020-03-17T13:40:27Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)\
**Post date:** [Março 18, 2020, 1:09pm UTC](https://meta.discourse.org/t/the-correct-order-of-restoring-uploads/144582/2 "2020-03-18T13:09:52Z")

</div>

O seguinte deve funcionar, desde que você não tenha alterado o nome do host.

Entre no console do Rails:

```plaintext
cd '/var/discourse
./launcher enter app
rails c

```

Execute o seguinte:

```plaintext
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

```

Em seguida, saia do console do Rails e execute uma tarefa rake:

```plaintext
exit

rake posts:rebake_uncooked_posts

```

---

_[View the full topic](https://meta.discourse.org/t/the-correct-order-of-restoring-uploads/144582)._
