새 호스트로 복원

스테이징 환경을 구축하기 위해 새 호스트를 설정했습니다. 동일한 버전이어야 할 것으로 보이는 Discourse 설치를 다시 생성했습니다. 현재 실행 중인 버전은 2.8.2입니다.

첫 번째 코멘트로, 버전 2.8.2 기준으로 백업 크기가 282MB에서 약 90MB로 줄었습니다. 이유는 모르겠지만, 이를 활용하는 데 있어 추가된 지능(intelligence) 덕분에 이점을 누리고 있다고 생각하겠습니다.

포럼에서 최신 아카이브를 다운로드하여 새 스테이징 환경의 로컬 저장소에 업로드했습니다.

다음 오류로 인해 복원이 실패했습니다:

[2022-02-27 19:41:18] ALTER TABLE
[2022-02-27 19:41:18] ALTER TABLE
[2022-02-27 19:41:18] Migrating the database...
[2022-02-27 19:43:00]
[2022-02-27 19:43:00] Reconnecting to the database...
[2022-02-27 19:43:00] Reloading site settings...
[2022-02-27 19:43:00] Disabling outgoing emails for non-staff users...
[2022-02-27 19:43:02] Disabling readonly mode...
[2022-02-27 19:43:02] Clearing category cache...
[2022-02-27 19:43:02] Reloading translations...
[2022-02-27 19:43:02] Remapping uploads...
[2022-02-27 19:43:02] Remapping 'https://forum.geekbeacon.org' to 'https://forum-staging.geekbeacon.org'
[2022-02-27 19:43:08] Restoring uploads, this may take a while...
[2022-02-27 19:43:36] EXCEPTION: 8 posts are not remapped to new S3 upload URL. S3 migration failed for db 'default'.
[2022-02-27 19:43:36] /var/www/discourse/lib/file_store/to_s3_migration.rb:132:in `raise_or_log'
/var/www/discourse/lib/file_store/to_s3_migration.rb:87:in `migration_successful?'
/var/www/discourse/lib/file_store/to_s3_migration.rb:373:in `migrate_to_s3'
/var/www/discourse/lib/file_store/to_s3_migration.rb:66:in `migrate'
/var/www/discourse/lib/file_store/s3_store.rb:317:in `copy_from'
/var/www/discourse/lib/backup_restore/uploads_restorer.rb:62:in `restore_uploads'
/var/www/discourse/lib/backup_restore/uploads_restorer.rb:44:in `restore'
/var/www/discourse/lib/backup_restore/restorer.rb:61:in `run'
/var/www/discourse/script/spawn_backup_restore.rb:23:in `restore'
/var/www/discourse/script/spawn_backup_restore.rb:36:in `block in <main>'
/var/www/discourse/script/spawn_backup_restore.rb:4:in `fork'
/var/www/discourse/script/spawn_backup_restore.rb:4:in `<main>'
[2022-02-27 19:43:36] Trying to rollback...
[2022-02-27 19:43:36] Rolling back...
[2022-02-27 19:43:36] Cleaning stuff up...
[2022-02-27 19:43:36] Dropping functions from the discourse_functions schema...
[2022-02-27 19:43:36] Removing tmp '/var/www/discourse/tmp/restores/default/2022-02-27-194051' directory...
[2022-02-27 19:43:36] Unpausing sidekiq...
[2022-02-27 19:43:36] Marking restore as finished...
[2022-02-27 19:43:36] Notifying 'csgeek' of the end of the restore...

이것이 문제입니다. 같은 S3 버킷을 사용하고 있는지 확인해 보세요. "다운로드 S3 in backup"과 유사한 이름의 숨겨진 설정이 켜져 있는지 확인해 보세요. 설정 이름을 찾으려면 검색하거나 소스 코드를 살펴봐야 합니다.

또는 프로덕션 사이트의 나머지 업로드 파일들이 S3에 있는지 확인해야 할 수도 있습니다.

S3가 구성되어 있지 않은 것 같습니다. 아마도 구 서버에 유효한 S3 위치로 매핑되지 않은 오래된 데이터가 남아 있는 것 같습니다.

구 서버로 돌아가 보니 2개의 버킷이 구성되어 있습니다. 하나는 백업용, 다른 하나는 미디어용입니다. 가이드를 따라 AWS S3와 CDN을 설정했습니다.

실행에 실패한 rake uploads:migrate_to_s3 명령을 실행한 후 posts:rebake를 실행해 보았더니 오류 수가 줄어든 것 같지만, 여전히 실패합니다:

Please note that migrating to S3 is currently not reversible!
[CTRL+c] to cancel, [ENTER] to continue

Migrating uploads to S3 for 'default'...
Uploading files to S3...
 - Listing local files
 => 208 files
 - Listing S3 files
. => 978 files
 - Syncing files to S3
................................................................................................................................................................................................................
Updating the URLs in the database...
Removing old optimized images...
Flagging all posts containing lightboxes for rebake...
15 posts were flagged for a rebake
rake aborted!
FileStore::ToS3MigrationError: 1 posts are not remapped to new S3 upload URL. S3 migration failed for db 'default'.
/var/www/discourse/lib/file_store/to_s3_migration.rb:132:in `raise_or_log'
/var/www/discourse/lib/file_store/to_s3_migration.rb:87:in `migration_successful?'
/var/www/discourse/lib/file_store/to_s3_migration.rb:373:in `migrate_to_s3'
/var/www/discourse/lib/file_store/to_s3_migration.rb:66:in `migrate'
/var/www/discourse/lib/tasks/uploads.rake:123:in `migrate_to_s3'
/var/www/discourse/lib/tasks/uploads.rake:102:in `block in migrate_to_s3_all_sites'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rails_multisite-4.0.0/lib/rails_multisite/connection_management.rb:80:in `with_connection'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rails_multisite-4.0.0/lib/rails_multisite/connection_management.rb:90:in `each_connection'
/var/www/discourse/lib/tasks/uploads.rake:100:in `migrate_to_s3_all_sites'
/var/www/discourse/lib/tasks/uploads.rake:96:in `block in <main>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Tasks: TOP => uploads:migrate_to_s3
(See full trace by running task with --trace)

문제를 일으키는 게시물을 식별하기 위해 migrate_to_s3를 상세 모드(verbose mode)로 실행하는 방법이 있을까요?

저도 같은 문제를 겪고 있습니다. s3 버킷을 변경하지 않고 myserver를 마이그레이션하는 중이거든요.
어떤 제안이 있을까요?

복구 과정에서 다음과 같은 오류가 발생하고 있나요?

FileStore::ToS3MigrationError: 1 posts are not remapped to new S3 upload URL. S3 migration failed for db 'default'.

이 경우 가장 좋은 방법은 업로드가 잘못된 위치에 있는 게시물을 수정하는 것입니다. 하지만 이 테스트에서 오탐(false positive)이 발생할 수 있는 경우가 있다고 생각합니다. 그런 경우에는 rake 작업에 있는 스위치를 사용하여 프로세스를 일시 중지하고 문제를 수정할 수 있습니다. 제가 빠르게 찾지 못하고 있으며, 이 정보가 있어야 할 곳인 Backup discourse from the command line 에도 없습니다. 현재 다른 작업을 진행 중이라 당장 찾지 못하겠습니다.

네, 이런 유형의 오류가 발생합니다.

EXCEPTION: 3개의 게시물이 새로운 S3 업로드 URL로 재매핑되지 않았습니다. ‘default’ 데이터베이스에 대한 S3 마이그레이션이 실패했습니다.

다음과 같이 시도해 볼 수 있습니다

discourse restore --pause filename

이렇게 하면 복원 작업이 일시 중지되고, 다른 터미널에서 데이터베이스를 수정하여 문제를 해결할 수 있습니다. 또는, 그 확인 작업이 실행되기 전에 그냥 중지할 수도 있다고 생각합니다.

이것은 커맨드 라인 복원 시 사용해야 할 것 같습니다

같은 오류:

S3로 파일 업로드 중…

* 로컬 파일 목록 조회
  => 2개 파일
* S3 파일 목록 조회
  … => 183549개 파일
* S3로 파일 동기화 중
  ..
* 데이터베이스의 URL 업데이트 중…
* 오래된 최적화 이미지 삭제 중…
* 라이트박스(lighbox)를 포함한 모든 게시물을 재처리(rebake) 대상으로 표시 중…
  169809개 게시물이 재처리 대상으로 표시되었습니다.
  **예외: 3개 게시물이 새 S3 업로드 URL로 재매핑되지 않았습니다. db 'default'의 S3 마이그레이션이 실패했습니다.**
  /var/www/discourse/lib/file_store/to_s3_migration.rb:132:in `raise_or_log' /var/www/discourse/lib/file_store/to_s3_migration.rb:81:in `migration_successful?’
  /var/www/discourse/lib/file_store/to_s3_migration.rb:385:in `migrate_to_s3' /var/www/discourse/lib/file_store/to_s3_migration.rb:59:in `migrate’
  /var/www/discourse/lib/file_store/s3_store.rb:367:in `copy_from' /var/www/discourse/lib/backup_restore/uploads_restorer.rb:69:in `restore_uploads’
  /var/www/discourse/lib/backup_restore/uploads_restorer.rb:49:in `restore' /var/www/discourse/lib/backup_restore/restorer.rb:179:in `restore_uploads’
  /var/www/discourse/lib/backup_restore/restorer.rb:72:in `run' script/discourse:243:in `restore’
  /var/www/discourse/vendor/bundle/ruby/3.3.0/gems/thor-1.4.0/lib/thor/command.rb:28:in `run' /var/www/discourse/vendor/bundle/ruby/3.3.0/gems/thor-1.4.0/lib/thor/invocation.rb:127:in `invoke_command’
  /var/www/discourse/vendor/bundle/ruby/3.3.0/gems/thor-1.4.0/lib/thor.rb:538:in `dispatch' /var/www/discourse/vendor/bundle/ruby/3.3.0/gems/thor-1.4.0/lib/thor/base.rb:584:in `start’
  script/discourse:397:in `<top (required)>' /usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.4/lib/bundler/cli/exec.rb:59:in `load’
  /usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.4/lib/bundler/cli/exec.rb:59:in `kernel_load' /usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.4/lib/bundler/cli/exec.rb:23:in `run’
  /usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.4/lib/bundler/cli.rb:452:in `exec' /usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.4/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run’
  /usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command' /usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.4/lib/bundler/vendor/thor/lib/thor.rb:538:in `dispatch’
  /usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.4/lib/bundler/cli.rb:35:in `dispatch' /usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.4/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start’
  /usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.4/lib/bundler/cli.rb:29:in `start' /usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.4/exe/bundle:28:in `block in <top (required)>’
  /usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.4/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors' /usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.4/exe/bundle:20:in `<top (required)>’
  /usr/local/bin/bundle:25:in `load' /usr/local/bin/bundle:25:in `’
  롤백 시도 중…
  롤백 진행 중…
  정리 작업 수행 중…
  discourse_functions 스키마에서 함수 삭제 중…
  임시 '/var/www/discourse/tmp/restores/default/2026-01-13-145033' 디렉터리 삭제 중…
  sidekiq 일시정지 해제 중…
  복원 완료로 표시 중…
  'system'에게 복원 종료 알림 전송 중…
  완료!

그 세 개의 업로드를 수정하거나, 해당 체크가 실행되기 전에 복원을 중단해야 합니다.

3 post on 168000을 어떻게 찾을 수 있나요?

이 veryfing을 건너뛰고 복원을 중지할 수 있을까요?

그 테스트를 수행하는 코드를 살펴본 후 동일한 쿼리를 실행해 보세요. 이전에 해당 작업을 수행하는 코드를 게시했을 수도 있습니다.

저는 다음을 게시했습니다.

그렇게 했나요? 복원이 완료된 후 단순히 control-c를 누르면 될 것 같습니다. 데이터베이스만 복원하고 계신 건가요?

아, 데이터베이스는 복원하고 업로드는 하기 전에 복원을 중단하는 것에 대해 생각하지 못했네요.
S3에서 업로드 파일을 옮길 필요는 없습니다 — 프론트엔드와 데이터베이스만 마이그레이션해도 될까요?

포스트 관련 rake 작업을 중단하고 문제 있는 항목을 식별할 수 있는 옵션이 무엇인지 알려주실 수 있을까요? 정말 감사하겠습니다.

제안해 주실 수 있을까요? 감사합니다.