Discoruse 恢复踩坑记 S3

这次恢复站点的时候出现的问题是 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 次,不要删除老服务器,不要删除老服务器。

是的,我一般都是先停掉容器,然后迁移,迁移成功之后才会删除老服务器的容器

为什么要选中S3呢?为什么不使用1panel的。

让论坛的备份 和 计划任务 慢 4个小时 并且只保留一份 这样不就可以每个月备份之后 都会自动上传了嘛。

因我们很多服务都使用了 S3,不仅仅是 Discourse 的数据备份。

同时 CDN 也是用的 S3,就绑定在一起用了。

如果不是特殊情况,我们也不会在服务器上装其他管理软件,都是整机单独运行跑的。

这个是备份在服务器上吗还是上传到哪里

没想到正好我想迁移服务器你们也迁移了 不过我去年迁移过一次 当时没有特意设置s3也没有出问题 这次准备再尝试一下

S3 的问题不要忽视。

另外在迁移之前,老服务器最好全部更新,重构一次,所有的内容 rebake 一次。

这样能省下不少麻烦。

你们是换到国内的服务器了吗?我只是想2G换4G

没有,还是外面的服务器。

国内的服务器主要是用来测试仓库的。

完了 我都禁用不了这个选项 说我开启了全局了S3上传