How to migrate old uploads to S3?

I now have all new uploads going straight to S3 but now I’d like to move all previous uploads to S3 as well. Is there a How To for this?

I searched the forums and found bits and pieces but not a step by step guide. I was unable to figure it out so far.

You should be able to use the uploads:migrate_to_s3 rake command. This would migrate your local files to the configured S3 bucket.

3 Likes

Hi guys,

I’m in the same boat. But i already moved the /uploads/ folder to it’s new S3. Is there an alternative to uploads:migrate_to_s3 that only relinks but skips actual uploading?

I just switched my instance from local to S3 uploads and I could not for the life of me figure out how to get the S3 migrator to work. In the interest of anyone else who stops by this topic, I will summarize the required steps here.

  1. Enable S3 Uploads in the admin interface and set all of the required S3 keys and settings so new uploads are sent to S3
  2. Add the required DISCOURSE_S3_ env variables to the env section of app.yml
    Example:
  DISCOURSE_S3_BUCKET: your-bucket-name
  DISCOURSE_S3_REGION: your-s3-bucket-region
  DISCOURSE_S3_ACCESS_KEY_ID: your-s3-access-key-id
  DISCOURSE_S3_SECRET_ACCESS_KEY: your-s3-secret-access-key
  1. Rebuild your app with ./launcher rebuild app
  2. Enter the app with ./launcher enter app
  3. Run rails uploads:migrate_to_s3 from within the docker container.

I initially tried to run the command using ./launcher run app rails uploads:migrate_to_s3 but it couldn’t find the task.

4 Likes