这次恢复站点的时候出现的问题是 S3。
[2025-03-06 15:42:10] Reconnecting to the database...
[2025-03-06 15:42:10] Reloading site settings...
[2025-03-06 15:42:10] Disabling outgoing emails for non-staff users...
[2025-03-06 15:42:10] Disabling readonly mode...
[2025-03-06 15:42:10] Clearing category cache...
[2025-03-06 15:42:10] Reloading translations...
[2025-03-06 15:42:10] Remapping uploads...
[2025-03-06 15:42:10] Remapping 'https://www.zchub.net' to 'http://www.zchub.net'
[2025-03-06 15:42:17] Restoring uploads, this may take a while...
[2025-03-06 15:43:41] EXCEPTION: 648 of 3118 uploads are not migrated to S3. S3 migration failed for db 'default'.
[2025-03-06 15:43:41] /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:73:in `migration_successful?'
/var/www/discourse/lib/file_store/to_s3_migration.rb:383: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:354: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:167:in `restore_uploads'
/var/www/discourse/lib/backup_restore/restorer.rb:71:in `run'
/var/www/discourse/script/spawn_backup_restore.rb:20:in `restore'
/var/www/discourse/script/spawn_backup_restore.rb:33: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>'
[2025-03-06 15:43:41] Trying to rollback...
[2025-03-06 15:43:41] Rolling back...
[2025-03-06 15:43:42] Cleaning stuff up...
[2025-03-06 15:43:42] Dropping functions from the discourse_functions schema...
[2025-03-06 15:43:42] Removing tmp '/var/www/discourse/tmp/restores/default/2025-03-06-154032' directory...
[2025-03-06 15:43:42] Unpausing sidekiq...
[2025-03-06 15:43:42] Marking restore as finished...
[2025-03-06 15:43:42] Notifying 'honeymoose' of the end of the restore...
出现这个情况后,整个恢复都会被回滚。
解决办法
解决办法根据官方的说法是: Restore from backup fails due to S3 migration - #2 by pfaffman - Support - Discourse Meta
在备份的时候需要临时禁用 enable_s3_uploads
选项。
如果遇到没有办法恢复的情况,我们在命令行运行到出现问题的位置的时候,直接 Ctrl+C 来终止恢复。
然后对所有的帖子内容重构一次。
非常重要的,在没有完全恢复之前,不要删除老的服务器。重要的话是说 3 次,不要删除老服务器,不要删除老服务器。