# Les anciennes images téléchargées deviennent des images cassées

**URL:** https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236
**Category:** Support
**Created:** [Juillet 13, 2016, 6:38 UTC](https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236 "2016-07-13T18:38:57Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![karussell](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/karussell/32/79339_2.png) [@karussell](https://meta.discourse.org/u/karussell)
#### Post date: [Septembre 25, 2017, 8:53 UTC](https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236/21 "2017-09-25T20:53:41Z")

</div>

Did this already, see [my comment](https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236/9) 😉

---

<div class="post-metadata">

### Author: ![peternlewis](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/peternlewis/32/108888_2.png) [@peternlewis](https://meta.discourse.org/u/peternlewis)
#### Post date: [Avril 6, 2018, 10:15 UTC](https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236/22 "2018-04-06T10:15:26Z")

</div>

I have had a few reports of lost uploaded images (images show as missing in posts that have not been edited for ages). Usually by the time they are reported, the user has fixed the issue, but in this case I got a report of an issue and managed to look more deeply.

```
<img src="/uploads/default/original/2X/d/d55cbd4c2d65cac5415340df0a4567ca805efa2d.png" width="575" height="954">

<img src="/uploads/default/original/2X/5/5e93bafe11e13c7af89d91a976e01a919538c486.png" width="498" height="304">

```

(from [this post](https://forum.keyboardmaestro.com/t/finder-move-selected-finder-items-to-choose-folder-example/4630)).

The post was written in Aug 2016, and updated in Feb 2017, and then not touched since then.

I checked in to this and I can see that the files have been removed from the uploads directory sometime in January 2018 (they are in my backups from the end of December 2017, but not in my backups from the end of January).

So somewhere along the lines something went wrong and these files were removed even though they were referenced.

I have checked on the server and the files do not appear to exist in any directory anywhere. What does `recover_from_tombstone` do and is it likely to help?

Alternatively, how can I restore the individual files from the backups?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [Avril 6, 2018, 12:25 UTC](https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236/23 "2018-04-06T12:25:54Z")

</div>

I’ve got an import running now that may have the same problem. I’d try the recover from tombstone task. It could be that there is a bug that tombstones images when they shouldn’t be..

Do you see the missing file in tombstone?

They stay in tombstone 30 days before getting deleted. So if they were moved in January, they were deleted in February.

---

<div class="post-metadata">

### Author: ![peternlewis](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/peternlewis/32/108888_2.png) [@peternlewis](https://meta.discourse.org/u/peternlewis)
#### Post date: [Avril 6, 2018, 11:14 UTC](https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236/24 "2018-04-06T23:14:32Z")

</div>

They were definitely gone before Jan 31, so presumably they wont be in tombstone.

> [@pfaffman](#):
>
> Do you see the missing file in tombstone?

Where do I look for that? Though, as I say, they are presumably long gone from that.

So it seems there is some sort of bug in that code that is deleting images that are referenced.

I still would like to know an easy way to restore them if I have the file, since I always have the file in a backup from some time in the past.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [Avril 6, 2018, 11:20 UTC](https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236/25 "2018-04-06T23:20:42Z")

</div>

> [@peternlewis](#):
>
> They were definitely gone before Jan 31, so presumably they wont be in tombstone.

Right. But I thought you said that you had old backups. They’ll be in that tar file. Or wherever you have the backups you mention.

You can just put them back where they belong. They may get deleted again, but then it’ll be in the tombstone and the recover\_from\_tombstone will work.

---

<div class="post-metadata">

### Author: ![peternlewis](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/peternlewis/32/108888_2.png) [@peternlewis](https://meta.discourse.org/u/peternlewis)
#### Post date: [Avril 7, 2018, 5:54 UTC](https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236/26 "2018-04-07T05:54:47Z")

</div>

> [@pfaffman](#):
>
> Right. But I thought you said that you had old backups. They’ll be in that tar file. Or wherever you have the backups you mention.

The backups (from Discourse backups) do not appear to include the `uploads/tombstone` directory.

I have restored the files on the site to their places in the uploads folder, and they have reappeared in the topic post. I will try to monitor the topic and see if they are deleted again.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [Avril 7, 2018, 10:39 UTC](https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236/27 "2018-04-07T10:39:50Z")

</div>

Right. You’ll need to go back to backups from before they were tombstoned.

---

<div class="post-metadata">

### Author: ![JMichaelTX](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jmichaeltx/32/54116_2.png) [@JMichaelTX](https://meta.discourse.org/u/JMichaelTX)
#### Post date: [Juin 1, 2018, 1:45 UTC](https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236/28 "2018-06-01T01:45:38Z")

</div>

> [@pfaffman](#):
>
> It could be that there is a bug that tombstones images when they shouldn’t be…

Is anyone investigating a bug?

It is very time consuming for the site admin to investigate, find, and restore broken images. And the worst part is that images can become broken without anyone being notified.

Any help to find/fix this bug would be greatly appreciated.

---

<div class="post-metadata">

### Author: ![mustachianpost](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mustachianpost/32/111646_2.png) [@mustachianpost](https://meta.discourse.org/u/mustachianpost)
#### Post date: [Septembre 21, 2018, 8:24 UTC](https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236/29 "2018-09-21T20:24:05Z")

</div>

Hi there,

I tried to run your commands to fix broken image on my forum: [Investing / Brokers FAQ - Wiki - Mustachian Post Community](https://forum.mustachianpost.com/t/investing-brokers-faq/999)

Before it was showing a broken link. But not it seems to have replaced it by a “transparent” image.  
Any clue why/how to fix the issue definitely?

Many thanks for your help!  
MP

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [Septembre 21, 2018, 9:25 UTC](https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236/30 "2018-09-21T21:25:50Z")

</div>

I believe @tgxworld added a bunch of extra tooling here so maybe there are new things to try?

---

<div class="post-metadata">

### Author: ![qtpngo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/qtpngo/32/112051_2.png) [@qtpngo](https://meta.discourse.org/u/qtpngo)
#### Post date: [Septembre 28, 2018, 3:21 UTC](https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236/31 "2018-09-28T03:21:48Z")

</div>

I still got this issue with the newest update from Discourse: 2.2.0.beta2 +45.  
Followed the instruction in this reply I solved the issue.

> [@pfaffman](#):
>
> Though you will probably never need it, the fix went something like this:
> 
> ```plaintext
> # copy the "deleted" images from their to-be-deleted staging area
> cd /var/discourse
> ./launcher enter app
> rake uploads:recover_from_tombstone
> 
> # rebake to see that it doesn't happen again
> rake posts:rebake
> 
> ```

Is there any update on this? 🙂

---

<div class="post-metadata">

### Author: ![mustachianpost](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mustachianpost/32/111646_2.png) [@mustachianpost](https://meta.discourse.org/u/mustachianpost)
#### Post date: [Octobre 1, 2018, 6:34 UTC](https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236/32 "2018-10-01T06:34:01Z")

</div>

@tgxworld @pfaffman so I tried running this:

> # copy the “deleted” images from their to-be-deleted staging area
> 
> cd /var/discourse  
> ./launcher enter app  
> rake uploads:recover\_from\_tombstone
> 
> # rebake to see that it doesn’t happen again
> 
> rake posts:rebake

Then, now, all missing images are still transparent.png, and have a data-orig-src with what seems to be the uploaded file…

 ![50](https://global.discourse-cdn.com/meta/original/3X/8/7/87aa56b78e5d077af109803fcff870e6a24fdd17.png)

Anyhow, I still have 748 images that seems problematic…

Do you have any new tooling to definitely fix this? That would help a lot!  
Even if it’s manually copy-pasting from tombstone to the uploads folder (I’d just need to know the paths then I could try).

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [Octobre 1, 2018, 6:51 UTC](https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236/33 "2018-10-01T06:51:12Z")

</div>

The instructions in this post are stale. Please follow the steps in

[https://meta.discourse.org/t/my-forum-old-images-not-see/97123/22?u=tgxworld](https://meta.discourse.org/t/my-forum-old-images-not-see/97123/22)

instead.

---

<div class="post-metadata">

### Author: ![mustachianpost](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mustachianpost/32/111646_2.png) [@mustachianpost](https://meta.discourse.org/u/mustachianpost)
#### Post date: [Octobre 1, 2018, 7:00 UTC](https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236/34 "2018-10-01T07:00:42Z")

</div>

> [@tgxworld](#):
>
> ./launcher enter app rails c require\_dependency “upload\_recovery” UploadRecovery.new.recover

Thanks @tgxworld  
Just did run it and so far it outputs:

```
rails.c
require_dependency "upload_recovery"
UploadRecovery.new.recover
[1] pry(main)> require_dependency "upload_recovery"
=> nil
[2] pry(main)> UploadRecovery.new.recover
=> nil
[3] pry(main)>

```

Should I type exit to end the thing and see if it works? Or should I just wait because many images? (sorry, newbie in Ruby 🙂)

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [Octobre 1, 2018, 11:10 UTC](https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236/35 "2018-10-01T11:10:30Z")

</div>

Have you upgraded recently? I’m guessing not.

```
./launcher rebuild app

```

---

<div class="post-metadata">

### Author: ![mustachianpost](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mustachianpost/32/111646_2.png) [@mustachianpost](https://meta.discourse.org/u/mustachianpost)
#### Post date: [Octobre 1, 2018, 4:51 UTC](https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236/36 "2018-10-01T16:51:51Z")

</div>

> [@mustachianpost](#):
>
> ./launcher enter app

@pfaffman yep I did so last weekend, but re-did it again now.  
Still the same output:

```
rails c
[1] pry(main)> require_dependency "upload_recovery"
=> nil
[2] pry(main)> UploadRecovery.new.recover
=> nil
[3] pry(main)> 

```

Any clue what else I could do to fix those missing images?

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [Octobre 2, 2018, 12:56 UTC](https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236/37 "2018-10-02T00:56:52Z")

</div>

You can run `UploadRecovery.new(dry_run: true).recover` to see what images are still missing. For those that are, you’ll have to recover the images from a recent backup.

---

<div class="post-metadata">

### Author: ![mustachianpost](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mustachianpost/32/111646_2.png) [@mustachianpost](https://meta.discourse.org/u/mustachianpost)
#### Post date: [Octobre 2, 2018, 4:59 UTC](https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236/38 "2018-10-02T04:59:53Z")

</div>

> [@tgxworld](#):
>
> UploadRecovery.new(dry\_run: true).recover

Thanks for the tip!  
Interesting because now it lists only 3 missing images, but that I can’t seem to find in Discourse backups…  
Will check if I have more chances with DigitalOcean ones.

---

<div class="post-metadata">

### Author: ![mustachianpost](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mustachianpost/32/111646_2.png) [@mustachianpost](https://meta.discourse.org/u/mustachianpost)
#### Post date: [Octobre 2, 2018, 5:36 UTC](https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236/39 "2018-10-02T05:36:44Z")

</div>

OK so in the end everything is fine!  
FTR what I did:

- Taking a discourse backup (not the one from Digital Ocean, but the one done by Discourse itself)
- At first I looked at the filenames returned by “UploadRecovery.new(dry\_run: true).recover” which I couldn’t find in the “original” upload folder nor in the “optimized” one
- So what I did was to go look for the original filename within the forum where the image was missing, and here I got the “original” filename (as the Ruby request returns the optimized filename it seems)
- Then I went into my backup file (a tar.gz that I downloaded on my laptop) and searched for the (original) filename in the folder “/uploads/default/original/1X”.

HTH.

And thanks again for your support @tgxworld and @pfaffman !

---

<div class="post-metadata">

### Author: ![Brandon\_Martus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/brandon_martus/32/127631_2.png) [@Brandon\_Martus](https://meta.discourse.org/u/Brandon_Martus)
#### Post date: [Janvier 4, 2019, 11:03 UTC](https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236/40 "2019-01-04T23:03:30Z")

</div>

I’ve had a similar issue happen after importing my 2M posts from vBulletin.

Currently running through `rake uploads:recover_from_tombstone` over 46,000 files.

This is taking a long time – 2.6% in the past 8 hours. Is there something I should do to prevent the tombstone files from being removed while this is running?

Is this setting below applicable or is it just for s3?

 ![image](https://global.discourse-cdn.com/meta/original/3X/6/7/67a46f09c25aaeabd58fe7aa6df6b0817e9ff5c3.png)

Thanks!

[Page précédente](https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236.md?page=1)

[Page suivante](https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236.md?page=3)
