Migrando uploads do S3 para 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 curtidas

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 curtidas

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

1 curtida

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 curtida

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 curtida

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 curtidas

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 curtidas

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.

5 curtidas

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 curtidas

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

1 curtida

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

1 curtida

Is there a way to find these hidden settings?

2 curtidas

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 curtidas

Esta tarefa rake não está mais disponível no 2.9.0 BETA 8

Alguém tem ideias de como migrar do S3 para o local?

1 curtida

Você pode ativar a configuração oculta do site chamada algo como download_s3_with_backups (não é bem isso, mas não consigo encontrar no meu celular agora) e, em seguida, restaurar esse backup. É isso que acontece quando você sai da hospedagem cdck, e funciona. Talvez você precise restaurar para um servidor diferente (e você faria isso de qualquer maneira para testar).

Editar: obrigado @Benjamin_D! é include_s3_uploads_in_backups

2 curtidas

Acho que é isto:

4 curtidas

Essa opção não está disponível na página de Configurações nos controles do site do administrador, na página de Configurações de Backup? E isso não é o oposto de baixar os arquivos S3?

1 curtida

Não.

backup_with_uploads não é o mesmo que include_s3_uploads_in_backups. Um inclui arquivos locais no backup. O outro baixa cada arquivo do s3 toda vez que você faz um backup. E o objetivo do s3 é que você não precise fazer backups dele.

3 curtidas

Então isso inclui arquivos locais ao fazer backup para o S3

Isso baixa arquivos do armazenamento S3 para incluir no backup (que pode ser local ou no S3)


Estou tentando entender os passos corretos aqui, o objetivo é migrar todos os arquivos do S3 para o local, então se eu entendi o que você está dizendo:

  1. Habilitar backup_with_uploads do console do rails
  2. Criar um backup (local ou no S3)
  3. Restaurar usando o backup
  4. Desabilitar backup_with_uploads do console do rails

Está correto?

1 curtida

Então, qual é a melhor abordagem para mover do S3 para o local? :slight_smile:

  • Mover manualmente os arquivos (pastas optimized/original) e fazer um pós-rebake após desativar a opção S3 do Discourse?
  • Usar a opção de administrador download_s3_with_backups sombreada, baixar e descompactar esses arquivos?
  • rake uploads:migrate_from_s3?
1 curtida