# "EXCEPTION: x of y uploads are not migrated to S3. S3 migration failed for db 'default'." 恢复失败

**URL:** <https://meta.discourse.org/t/restore-failed-at-exception-x-of-y-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/171100>\
**Category:** Self-hosting\
**Created:** [2020年十一月24日 00:03 UTC](https://meta.discourse.org/t/restore-failed-at-exception-x-of-y-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/171100 "2020-11-24T00:03:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dltj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dltj/32/114914_2.png) [@dltj](https://meta.discourse.org/u/dltj)\
**Post date:** [2020年十一月24日 00:03 UTC](https://meta.discourse.org/t/restore-failed-at-exception-x-of-y-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/171100/1 "2020-11-24T00:03:21Z")

</div>

这封帖子在 [meta.discourse.org](http://meta.discourse.org) 上作为草稿存放了一段时间，当时我正在我的 Discourse 服务器上处理该问题。我已经能够绕过下面描述的问题，但无法执行有效的灾难恢复（即在不进入旧服务器且该服务器已损坏的情况下进行恢复）令人担忧。（根本原因是 Postgres 10 到 12 的升级失败，但我能够在 Discourse 的 `app.yml` 文件中[推迟更新](https://meta.discourse.org/t/postgresql-12-update/151236#postponing-the-update)，以便在创建备份之前禁用 `enable_s3_uploads` 站点设置。我现在已经完成了该备份，将其上传到新服务器，进行了恢复，Discourse 站点现已重新运行。原始消息如下：

* * *

我正在从存储在 S3 上的备份重建 Discourse 安装。旧安装非常古老——首次安装于 2016 年 6 月。由于 Postgres 10 到 12 的升级失败，我从全新安装开始进行恢复。与其修复该问题……既然这台服务器运行的是不再受支持的 Ubuntu 版本……我想直接采用最新的备份并将其加载到新服务器上。然而，恢复失败了。在日志中，我遇到问题的是以下位置：

```
[2020-11-23 22:27:32] 重新加载翻译...
[2020-11-23 22:27:32] 重新映射上传文件...
[2020-11-23 22:27:32] 正在恢复上传文件，这可能需要一些时间...
[2020-11-23 22:28:38] 异常：751 个上传文件中有 465 个未迁移到 S3。数据库 'default' 的 S3 迁移失败。
[2020-11-23 22:28:38] /var/www/discourse/lib/file_store/to_s3_migration.rb:131:in `raise_or_log'
/var/www/discourse/lib/file_store/to_s3_migration.rb:78:in `migration_successful?'
/var/www/discourse/lib/file_store/to_s3_migration.rb:357:in `migrate_to_s3'
/var/www/discourse/lib/file_store/to_s3_migration.rb:65:in `migrate'
/var/www/discourse/lib/file_store/s3_store.rb:238: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:64: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>'
[2020-11-23 22:28:38] 尝试回滚...

```

这听起来与 _[Restore process cancelled at migrating uploads to S3 step - #5 by Jim.Morrison](https://meta.discourse.org/t/restore-process-cancelled-at-migrating-uploads-to-s3-step/123233/5)_ 类似，但该帖子并未提供任何关于如何修复此问题的指导。

此撰写窗口右侧的“发帖前提示”消息也建议查看 \*[https://meta.discourse.org/t/failed-to-restore-db/131137\*，但该帖子也没有任何有用的内容。](https://meta.discourse.org/t/failed-to-restore-db/131137*%EF%BC%8C%E4%BD%86%E8%AF%A5%E5%B8%96%E5%AD%90%E4%B9%9F%E6%B2%A1%E6%9C%89%E4%BB%BB%E4%BD%95%E6%9C%89%E7%94%A8%E7%9A%84%E5%86%85%E5%AE%B9%E3%80%82)

---

<div class="post-metadata">

**Author:** ![RBoy](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@RBoy](https://meta.discourse.org/u/RBoy)\
**Post date:** [2022年六月9日 14:20 UTC](https://meta.discourse.org/t/restore-failed-at-exception-x-of-y-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/171100/3 "2022-06-09T14:20:00Z")

</div>

> [@dltj](#):
>
> file long enough to disable the `enable_s3_uploads` site setting before creating the backup. I’ve now done that backup, uploaded it to the new server, restored it, and have the Discourse site running again

I’m facing the same issue here but I haven’t been able to resolve it:

> [@Help restoring - system hung at midnight](https://meta.discourse.org/t/help-restoring-system-hung-at-midnight/229486/9):
>
> Thanks, my site has crashed unfortunately so I’m only left with the S3 uploads and back ups. I’m assuming there’s no way to for me to migrate any left over local files to the S3 now. So I’m wondering what are my options right now? Is there a way to restore from S3 backups and ignore the local files? I found a way to have it ignore the S3 upload but then pretty much all the posts have broken links/images (90%+ is probably in the S3 because I setup the S3 upload many many years ago).

Could you explain in more details what exactly you did here? Was this settings disabled in the Admin → Settings GUI page or was it on in app.yml? So after the backup, you were able to restore it and get everything back? Did you turn on this setting again after the backup? Thanks

---

<div class="post-metadata">

**Author:** ![dltj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dltj/32/114914_2.png) [@dltj](https://meta.discourse.org/u/dltj)\
**Post date:** [2022年六月10日 16:23 UTC](https://meta.discourse.org/t/restore-failed-at-exception-x-of-y-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/171100/4 "2022-06-10T16:23:41Z")

</div>

这是在编辑 app.yml 文件，是的，我已成功恢复所有内容。不幸的是，我没有记录下两年前的工作，细节也随着时间流逝而丢失了。我没有重新启用“在备份中包含上传文件”，但我认为我现在会这样做——希望我之前遇到的任何问题都已修复。

---

<div class="post-metadata">

**Author:** ![RBoy](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@RBoy](https://meta.discourse.org/u/RBoy)\
**Post date:** [2022年六月10日 17:36 UTC](https://meta.discourse.org/t/restore-failed-at-exception-x-of-y-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/171100/5 "2022-06-10T17:36:14Z")

</div>

恢复后，您在帖子中发现任何指向附件的损坏链接吗？

---

<div class="post-metadata">

**Author:** ![dltj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dltj/32/114914_2.png) [@dltj](https://meta.discourse.org/u/dltj)\
**Post date:** [2022年六月10日 18:54 UTC](https://meta.discourse.org/t/restore-failed-at-exception-x-of-y-uploads-are-not-migrated-to-s3-s3-migration-failed-for-db-default/171100/6 "2022-06-10T18:54:03Z")

</div>

据我回忆，没有。祝你好运！
