I’ve been running into issues trying to run a restore on our Staging Discourse instance. Staging is running v2.4.0.beta1 +36. Any idea where the breakdown might be or where to look? Thanks in advance!
Below is the end of the log output:
[2019-07-16 20:08:12] ALTER TABLE
[2019-07-16 20:08:12] ALTER TABLE
[2019-07-16 20:08:12] ALTER TABLE
[2019-07-16 20:08:12] ALTER TABLE
[2019-07-16 20:08:12] Migrating the database...
[2019-07-16 20:08:16] Reconnecting to the database...
[2019-07-16 20:08:16] Reloading site settings...
[2019-07-16 20:08:16] Disabling outgoing emails for non-staff users...
[2019-07-16 20:08:16] Clearing emoji cache...
[2019-07-16 20:08:16] Disabling readonly mode...
[2019-07-16 20:08:16] Clear theme cache
[2019-07-16 20:08:22] Extracting uploads...
[2019-07-16 20:08:40] Migrating uploads to S3...
[2019-07-16 20:08:46] Restore process was cancelled!
[2019-07-16 20:08:46] Trying to rollback...
[2019-07-16 20:08:46] Rolling back...
[2019-07-16 20:08:47] Cleaning stuff up...
[2019-07-16 20:08:47] Removing tmp '/var/www/discourse/tmp/restores/default/2019-07-16-200516' directory...
[2019-07-16 20:08:48] Unpausing sidekiq...
[2019-07-16 20:08:48] Marking restore as finished...
Below is the output after running discourse restore BACKUP_FILENAME from the command line. Any feedback is appreciated, thanks!
Disabling outgoing emails for non-staff users...
Clearing emoji cache...
Disabling readonly mode...
Clear theme cache
Extracting uploads...
Migrating uploads to S3...
Checking if default already migrated...
524 of 9474 uploads are not migrated to S3. S3 migration failed for db 'default'.
321 posts are not remapped to new S3 upload URL. S3 migration failed for db 'default'.
Looking for missing uploads on: default
Fixing missing uploads:
..........................................................................................................
116 post uploads are missing.
116 uploads are missing.
106 of 116 are old scheme uploads.
98 of 83342 posts are affected.
rake posts:missing_uploads identified 98 issues. S3 migration failed for db 'default'.
No posts require rebaking
Migrating uploads to S3 for 'default'...
Some uploads were not migrated to the new scheme. Please run these commands in the rails console
SiteSetting.migrate_to_new_scheme = true
Jobs::MigrateUploadScheme.new.execute(nil)
Restore process was cancelled!
Trying to rollback...
Rolling back...
Cleaning stuff up...
Removing tmp '/var/www/discourse/tmp/restores/default/2019-07-22-172918' directory...
Unpausing sidekiq...
Marking restore as finished...
Notifying 'system' of the end of the restore...
Finished!
[FAILED]
Restore done.
이 문제도 방금 겪은 것 같습니다. 버그로 표시되어야 한다고 생각합니다.
(다른 문제라면 별도의 새 주제로 옮기셔도 됩니다)
백업 복구가 정상적으로 작동하는 것은 상당히 중요합니다.
관리자 UI에서 백업 이름 옆의 복구를 클릭할 경우 실패 원인이 명확하지 않습니다. 다음과 같은 메시지가 표시됩니다:
...
Migrating uploads to S3...
Restore process was cancelled!
...
명령줄을 통해 복구를 완료하면 더 자세한 정보를 얻을 수 있습니다:
discourse enter app
discourse restore example-net-2020-01-02-033557-v20191219112000.tar.gz
...
Reconnecting to the database...
Reloading site settings...
Disabling outgoing emails for non-staff users...
Clearing emoji cache...
Disabling readonly mode...
Clear theme cache
Extracting uploads...
Remapping uploads...
Remapping '//forum-example-net.s3.dualstack.eu-west-2.amazonaws.com/' to '/uploads/default/'
optimized_images=3
uploads=1
Migrating uploads to S3...
Checking if default already migrated...
6 of 12 uploads are not migrated to S3. S3 migration failed for db 'default'.
1 posts are not remapped to new S3 upload URL. S3 migration failed for db 'default'.
Looking for missing uploads on: default
0 post uploads are missing.
Please provide the following environment variables
- DISCOURSE_S3_BUCKET
- DISCOURSE_S3_REGION
and either
- DISCOURSE_S3_ACCESS_KEY_ID
- DISCOURSE_S3_SECRET_ACCESS_KEY
or
- DISCOURSE_S3_USE_IAM_PROFILE
Restore process was cancelled!
Trying to rollback...
Rolling back...
Cleaning stuff up...
Dropping function from the discourse_functions schema
Removing tmp '/var/www/discourse/tmp/restores/default/2020-01-06-222212' directory...
Unpausing sidekiq...
Marking restore as finished...
Notifying 'system' of the end of the restore...
Finished!
[FAILED]
Restore done.
Please provide the following environment variables 바로 전에 uploads.rake에 디버그 코드를 추가하여 환경 변수를 덤프했습니다:
Contribute > Bug 로 전환할 필요는 없습니다. 제 담당 사항이며, 복원 프로세스를 리팩토링하고, 많은 테스트를 추가하며, 더 안정적으로 만드는 데 이미 상당한 시간을 투자했습니다. S3로의 복원이 깨질 가능성을 줄이고, 관리자 UI에서 더 많은 정보를 출력하도록 몇 가지 더 조정하겠습니다.
제 생각에는 백업/복원 기능이 재작성되었지만, 이것이 여전히 문제인 것을 방금 알게 되었습니다. enable s3 uploads가 활성화되어 있던 백업을 beta11에서 복원하려고 시도했지만 여전히 다음과 같은 오류가 발생합니다.
[2020-02-18 09:51:38] Restoring uploads, this may take a while...
[2020-02-18 09:51:38] EXCEPTION: Please provide the following environment variables:
- DISCOURSE_S3_BUCKET
- DISCOURSE_S3_REGION
and either
- DISCOURSE_S3_ACCESS_KEY_ID
- DISCOURSE_S3_SECRET_ACCESS_KEY
or
- DISCOURSE_S3_USE_IAM_PROFILE
[2020-02-18 09:51:38] /var/www/discourse/lib/file_store/to_s3_migration.rb:34:in `s3_options_from_env'
S3 액세스 자격 증명은 복원된 데이터베이스에 이미 존재하므로, 환경 변수로도 이를 요구할 필요가 없습니다.
환경 변수를 제공해도 여전히 실패합니다.
Restoring uploads, this may take a while...
Checking if db8015 already migrated...
200 of 206 uploads are not migrated to S3. S3 migration failed for db 'db8015'.
5 posts are not remapped to new S3 upload URL. S3 migration failed for db 'db8015'.
No posts require rebaking
Migrating uploads to S3 for 'db8015'...
Uploading files to S3...
- Listing local files
=> 21 files
- Listing S3 files
. => 16 files
- Syncing files to S3
.....................
Updating the URLs in the database...
Removing old optimized images...
Flagging all posts containing lightboxes for rebake...
5 posts were flagged for a rebake
EXCEPTION: 183 of 206 uploads are not migrated to S3. S3 migration failed for db 'db8015'.
/var/www/discourse/lib/file_store/to_s3_migration.rb:127:in `raise_or_log'
/var/www/discourse/lib/file_store/to_s3_migration.rb:74:in `migration_successful?'
/var/www/discourse/lib/file_store/to_s3_migration.rb:350:in `migrate_to_s3'
/var/www/discourse/lib/file_store/to_s3_migration.rb:61:in `migrate'
/var/www/discourse/lib/file_store/s3_store.rb:203:in `copy_from'
/var/www/discourse/lib/backup_restore/uploads_restorer.rb:48:in `restore_uploads'
/var/www/discourse/lib/backup_restore/uploads_restorer.rb:30:in `restore'
/var/www/discourse/lib/backup_restore/restorer.rb:58:in `run'
script/discourse:143:in `restore'
이것이 실패하는 이유를 알 수 없습니다.
대부분의 업로드가 이미 S3에 있었으므로, "200 of 206 uploads are not migrated to S3"와 "183 of 206 uploads are not migrated to S3"라는 메시지는 정확하지 않습니다. 로컬 파일 21개라는 수는 정확하며, S3에는 약 200개의 업로드가 있습니다(206개일 수도 있습니다). 다른 숫자들(183, 16)은 어디에서 나온 것인지 알 수 없습니다.
복원 프로세스가 왜 S3로 더 많은 업로드를 이동하려 하는지 역시 알 수 없습니다. 백업에서 로컬 이미지를 가져와 S3에 있는 업로드에는 손을 대지 않는 것이 정상이지 않나요? 아니면 제가 무언가를 놓치고 있는 건가요?
결국 데이터베이스 덤프의 enable_s3_uploads 설정을 false로 직접 수정(hack)했지만, 이로 인해 모든 것이 로컬로 다시 매핑되었습니다. 그리고 여전히 로컬에 남아 있는 몇몇 이미지들이 있어, 어떤 것은 S3로 다시 매핑해야 하고 어떤 것은 그대로 두어야 하는지 파악하는 데 많은 노력이 들었습니다.
로컬 업로드와 S3에 저장된 업로드를 혼합하는 것은 지원되지 않습니다. 네, 로컬에서 S3로 전환할 때 기존 업로드를 S3로 마이그레이션하지 않으면 이런 상태가 될 수 있다는 점은 알고 있습니다. 하지만 그것은 별개의 이야기입니다…
백업 복원 시에는 업로드 URL에 영향을 미치는 변경 사항이 감지되면 업로드의 재매핑이 항상 포함됩니다. 여기에는 스탠드얼론과 멀티사이트 간 전환, 로컬 업로드와 S3 간 전환, 그리고 S3 및 CDN 설정 변경이 포함됩니다. 설정에 따라 모든 업로드는 로컬 또는 S3의 올바른 위치에 복원됩니다.
가끔 자동 재매핑 및 S3 마이그레이션이 다양한 이유로 실패하는 백업을 만나기도 합니다. 2.5 개발 주기의 초기 단계에서 이러한 부분의 개선 사항을 더 많이 확인하실 수 있을 것입니다.