# S3로의 업로드 마이그레이션 실패

**URL:** https://meta.discourse.org/t/migrating-uploads-to-s3-fails/167134
**Category:** Self-hosting
**Tags:** s3
**Created:** [10월 13, 2020, 10:22오후 UTC](https://meta.discourse.org/t/migrating-uploads-to-s3-fails/167134 "2020-10-13T22:22:45Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![alexk](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@alexk](https://meta.discourse.org/u/alexk)
#### Post date: [10월 13, 2020, 10:22오후 UTC](https://meta.discourse.org/t/migrating-uploads-to-s3-fails/167134/1 "2020-10-13T22:22:45Z")

</div>

안녕하세요! 로컬 파일 업로드를 S3로 마이그레이션하는 데 큰 어려움을 겪고 있습니다.

아래와 같은 작업을 수행했습니다:

1. 새 환경으로 복원
2. “enable S3 uploads” 설정을 비활성화
3. 다음 명령 실행

```plaintext
rails c
SiteSetting.migrate_to_new_scheme = true
Jobs::MigrateUploadScheme.new.execute(nil) # 더 이상 시간이 오래 걸리지 않을 때까지 반복
exit
rake posts:rebake
rake uploads:recover
DISCOURSE_S3_REGION=us-east-1 DISCOURSE_S3_USE_IAM_PROFILE=true DISCOURSE_S3_BUCKET=<redacted> rake uploads:migrate_to_s3

```

기본적으로 아래 자료들을 참고했습니다: [How can I migrate files from the old upload scheme (default/XXX) to the new one (default/original/{1,2}X)? - #5 by kansaichris](https://meta.discourse.org/t/how-can-i-migrate-files-from-the-old-upload-scheme-default-xxx-to-the-new-one-default-original-1-2-x/110813/5)

> [@DO에서 S3로 업로드된 파일 마이그레이션](https://meta.discourse.org/t/migrating-uploaded-files-from-do-to-s3/153896):
>
> I was thinking to migrate all the files already uploaded to my discourse site to S3 and then continue serving them from S3 instead of Digital Ocean local disk. (I already managed to set-up the backups to be stored on another S3 bucket.) What is the correct procedure to set-up S3 for file uploads? If I just add the s3 upload bucket name and s3 cdn url names, enable Place uploads on Amazon S3 storage, and discourse will take care of the migration, or is there something else I need to do? Do I ne…

이제 막 해결책에 근접한 것 같은데, 다음 오류에서 막혀 있습니다:

```plaintext
** Invoke uploads:migrate_to_s3 (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute uploads:migrate_to_s3
Migrating uploads to S3 for 'default'...
Some uploads were not migrated to the new scheme. Running the migration, this may take a while...
rake aborted!
FileStore::ToS3MigrationError: Some uploads could not be migrated to the new scheme. You need to fix this manually.
/var/www/discourse/lib/file_store/to_s3_migration.rb:155:in `migrate_to_s3'
/var/www/discourse/lib/file_store/to_s3_migration.rb:65:in `migrate'
/var/www/discourse/lib/tasks/uploads.rake:245:in `migrate_to_s3'
/var/www/discourse/lib/tasks/uploads.rake:224:in `block in migrate_to_s3_all_sites'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rails_multisite-2.5.0/lib/rails_multisite/connection_management.rb:76:in `with_connection'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rails_multisite-2.5.0/lib/rails_multisite/connection_management.rb:86:in `each_connection'
/var/www/discourse/lib/tasks/uploads.rake:222:in `migrate_to_s3_all_sites'
/var/www/discourse/lib/tasks/uploads.rake:218:in `block in <main>'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `block in execute'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `each'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `execute'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:188:in `invoke'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:160:in `invoke_task'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `each'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block in top_level'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:125:in `run_with_threads'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:110:in `top_level'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:83:in `block in run'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:80:in `run'
bin/rake:13:in `<top (required)>'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
Tasks: TOP => uploads:migrate_to_s3

```

다음 단계로 무엇을 시도해야 할지 조언을 주실 수 있나요?

**수정:** 여기 더 많은 정보가 있습니다. 여전히 원본 스킴에 업로드된 파일이 있는 것 같습니다:

```plaintext
[1] pry(main)> Upload.where("url NOT LIKE '//%' AND url NOT LIKE '/uploads/default/original/_X/%'").exists?
=> true

```

---

<div class="post-metadata">

### Author: ![ajschmidt](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ajschmidt/32/453388_2.png) [@ajschmidt](https://meta.discourse.org/u/ajschmidt)
#### Post date: [10월 25, 2024, 10:19오후 UTC](https://meta.discourse.org/t/migrating-uploads-to-s3-fails/167134/2 "2024-10-25T22:19:48Z")

</div>

혹시 이 문제를 해결하셨나요? 저도 같은 문제를 겪고 있습니다.
