Migration des uploads de S3 vers 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 « J'aime »

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 « J'aime »

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

1 « J'aime »

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 « J'aime »

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 « J'aime »

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 « J'aime »

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 « J'aime »

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 « J'aime »

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 « J'aime »

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

1 « J'aime »

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

1 « J'aime »

Is there a way to find these hidden settings?

2 « J'aime »

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 « J'aime »

Cette tâche rake n’est plus disponible dans la version 2.9.0 BETA 8.

Quelqu’un a-t-il des idées sur la façon de migrer de S3 vers le local ?

1 « J'aime »

Vous pouvez activer le paramètre de site caché appelé quelque chose comme download_s3_with_backups (ce n’est pas tout à fait ça, mais je ne le trouve pas sur mon téléphone pour le moment) et ensuite restaurer cette sauvegarde. C’est ce qui se passe lorsque vous quittez l’hébergement cdck, et cela fonctionne. Vous pourriez avoir besoin de restaurer sur un serveur différent (et vous le feriez de toute façon pour tester).

Edit : merci @Benjamin_D ! c’est include_s3_uploads_in_backups

2 « J'aime »

Je pense que c’est ça :

4 « J'aime »

Cette option n’est-elle pas disponible sur la page des paramètres dans les contrôles du site Web d’administration, page des paramètres Sauvegarde ? N’est-ce pas aussi l’inverse du téléchargement des fichiers S3 ?

1 « J'aime »

Non.

backup_with_uploads n’est pas la même chose que include_s3_uploads_in_backups. L’un inclut les fichiers locaux dans la sauvegarde. L’autre télécharge chaque fichier depuis S3 à chaque sauvegarde. Et le but de S3 est que vous n’ayez pas besoin de faire de sauvegardes de celui-ci.

3 « J'aime »

Donc, cela inclut les fichiers locaux lors de la sauvegarde sur S3

Ceci télécharge les fichiers du magasin S3 pour les inclure dans la sauvegarde (qui peut être locale ou sur S3)


J’essaie de comprendre les bonnes étapes ici, le but est de migrer tous les fichiers de S3 vers le local, donc si je comprends bien ce que vous dites :

  1. Activer backup_with_uploads depuis la console Rails
  2. Créer une sauvegarde (locale ou sur S3)
  3. Restaurer en utilisant la sauvegarde
  4. Désactiver backup_with_uploads depuis la console Rails

Est-ce correct ?

1 « J'aime »

Alors, quelle est la meilleure approche pour passer de S3 à local ? :slight_smile:

  • Déplacer manuellement les fichiers (dossiers optimized/original) et effectuer un post-rebake après avoir désactivé l’option S3 de Discourse ?
  • Utiliser l’option d’administration masquée download_s3_with_backups, télécharger et décompresser ces fichiers ?
  • rake uploads:migrate_from_s3 ?
1 « J'aime »