새 호스트로 복원

I setup a new host so I can have a ‘staging’ environment. I re-created the same discourse installation with what should be the same version. I’m running version: 2.8.2.

First comment, as of version 2.8.2 my back up size has dropped from 282MB to around 90MB. Not sure why but I’m going to just with some intelligence added in that I’m taking advantage of.

I downloaded the latest archive from my forum, and uploaded to local storage on the new staging environment.

The restore fails due to:

[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...

This is your issue. Maybe use the same S3 bucket and use the same bucket? Maybe see that the hidden setting that’s called something like "download S3 in backup " is turned on. You’ll need to search or look on on the source for the setting name.

Or maybe you need to see that the rest of your uploads on the production site are on S3.

I have no S3 configured I’m guessing maybe the old server has some old data that didn’t get mapped to a valid S3 location.

I went back to the older server and I have 2 buckets configured, 1 for backups and 1 for media. I followed the guide and setup AWS S3 including the CDN.

When I run rake uploads:migrate_to_s3 which failed, I follwed that with a posts:rebake and that seems to have reduced the number of errors, but it still fails:

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)

Is there a way to run migrate_to_s3 in a verbose mode to identify the post that’s the culprit?

저도 같은 문제를 겪고 있습니다. 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 작업을 중단하고 문제 있는 항목을 식별할 수 있는 옵션이 무엇인지 알려주실 수 있을까요? 정말 감사하겠습니다.

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