Migrating uploads from s3 to local

I want to migrate my files from s3 back to local. I’m manually transferring all files from s3 to uploads folder. Then should be changing the base url of upload links, back to forum base url, sufficient to do the job done?

2 Likes

Why aren’t you using the built-in rake task? afaik it’s called uploads:migrate_from_s3

cd /var/discourse
./launcher enter app
rake uploads:migrate_from_s3

Then disable the enable s3 uploads site setting:

And finally rebake:

rake posts:rebake
4 Likes

Because my s3 is minio and I’m not sure if this function is compatible with it or not.

1 Like

I tried this and after it was done, I didnt see any change in uploads. Still uploads are served from s3. btw the rake task was wierd to me. It ended so fast while I have thousnds of s3 uploads. It shouldve taked a while.

1 Like

I have all my uploads transferred to local manually. Is there something that I can do to change all of the links in database and posts directly? I don’t need to use this rake task.

1 Like

Did you figure this out? I’m also looking to migrate all assets (everything except backups) from S3 back to the local. Is there an easy way to do this?

3 Likes

I too am looking for similar option. But I read somewhere on this very site, that for this to work correctly, some big problems are to be sorted first. So, for the time being, they recommend not to shift S3 to local.

Though I’m also anxiously waiting for the solution to this problem.

4 Likes

There is a hidden site setting called something like “download S3 uploads to local on backup”. I think you can use that and restore to another server (or maybe your server if you change settings with shadowed site settings in environment variables). This is what cdck does when you close an account and I’ve never had trouble restoring one of their backups.

4 Likes

I did commanded that setting in Rails console SiteSetting.include_s3_uploads_in_backups = true. But it still didn’t (seem to) have any effect. The backup still was the same size (approx 375 MB, even when my uploads are around 700 MB to 1GB).

If by ‘Shadowed site settings’ you mean all the S3 site settings in Disco Web UI, then I do have all those settings filled in those fields.

2 Likes

I’m also looking to migrate my uploads from S3 to local (separate VPS). Is there a documented procedure for this?

1 Like

Not really. I’d try using the setting I described above

1 Like

Is there a way to find these hidden settings?

2 Likes

The one that you might need in context of this discussion is mentioned above. You can see them all in site_settings.yml in the Discourse source.

3 Likes

This rake task is no longer available in 2.9.0 BETA 8

Anyone have an ideas how to migrate from S3 to local?

1 Like

You can turn on the hidden site setting that’s called something like download_s3_with_backups (that’s not quite right but I can’t find it on my phone right now) and then restore that backup. That’s what happens when you leave cdck hosting, and it works. You might need to restore to a different server (and u would anyway to test).

Edit: thanks @Benjamin_D! it’s include_s3_uploads_in_backups

1 Like

I think this is it:

3 Likes

Isn’t that option is available on the Settings page in the Admin website controls Backup Settings page? Also isn’t this the opposite of downloading the S3 files?

No.

backup_with_uploads is not the same as include_s3_uploads_in_backups. One includes local files in the backup. The other downloads every single file from s3 every time you make a backup. And the whole point of s3 is that you don’t need to make backups of it.

2 Likes

So this includes local files when backing up to the S3

This downloads files from the S3 store to include in the backup (which could be local or on the S3)


I’m trying to understand the right steps here, the goal is to migrate all files from S3 to local, so if I understand what you’re saying:

  1. Enable backup_with_uploads from the rails console
  2. Create a backup (either local or on S3)
  3. Restore using the backup
  4. Disable backup_with_uploads from the rails console

Is that correct?

So, what’s the actual best approach to move from S3 to local? :slight_smile:

  • Manually moving the files (optimized/original folders) and make a post-rebake after disabling the S3 option from Discourse?
  • Use the shadowed download_s3_with_backups admin option, download and unzip those files?
  • rake uploads:migrate_from_s3?