What happens if I manually move images out of the tombstone directory?

(John Lynch) #1

Recently, I’ve been migrating a bunch of data from an old forum (Google Spaces, actually) to my own Discourse instance. As part of this process, I uploaded a bunch of images through the Discourse API with the intent to reference them later from subsequent posts. I thought I had 30 days to do this, but it turns out that the default for moving things into the tombstone directory is just 2 days, and then they are gone entirely in 30 days. My mistake.

Now, all these images are uploaded to an S3 instance, as I do with all uploaded content. So (because it was late at night and I wasn’t thinking all that straight) I simply went into S3 and moved all the stuff out of the tombstone directory into the normal images directory, and made the content publicly accessible (as the “normal” uploads are). I was then able to refer to them from the posts as intended. After I did this, it occurred to me that perhaps this was not the greatest idea I have ever had.

So my question is:

What horrible thing have I done to Discourse’s internal bookkeeping by manually moving this stuff? Is there some image database that I’ve broken? Is there a task I can run to rebuild it? I’d turned off garbage collection (temporarily, I hope) at that point, and I want to reenable it, but I don’t want Discourse to re-tombstone these images. Any advice would be greatly appreciated.

Deleting user images when using the rails console to delete users
(Michael - DiscourseHosting.com) #2
cd /var/discourse 
./launcher enter app rake uploads:recover_from_tombstone

Should do the trick

(John Lynch) #3

I did see this, but two things:

  1. The comments/code for this indicated that it would not work on external storage. These images are all being automatically uploaded to an Amazon S3 bucket. Does that not count as external?
  2. I’ve already moved the images from the tombstone directory to the normal images directory. Since they aren’t physically in the tombstone anymore, will this be able to recover them?

Oh, and thanks for such a prompt reply!

EDIT: In other words, the physical images have already been moved. I just don’t know if Discourse has some additional bookkeeping information or database that also has to be updated.

(Jay Pfaffman) #4

I’m not an expert at this issue, but I’m pretty sure that your moving the stuff back to where you’re linking to them does pretty much what that rake task would do.

There’s certainly no harm in trying.

My guess is that it’ll be just fine unless Discourse still thinks they’re bad and deletes them again.

(Michael - DiscourseHosting.com) #5

No, there’s also an entry in the database that needs to be recovered.

(John Lynch) #6

Right. So will running the Rake task restore the database if the images have already been moved and they’re being stored in an S3 bucket? Again, the code indicates that the recover_from_tombstone function won’t work on external storage. It simply bails if this is the case.