# 备份还原失败，出现异常：错误：值超出字符型(1000)的长度

**URL:** https://meta.discourse.org/t/backup-restore-fails-with-exception-error-value-too-long-for-type-character-varying-1000/357850
**Category:** Support
**Tags:** backups
**Created:** [2025年三月18日 21:56 UTC](https://meta.discourse.org/t/backup-restore-fails-with-exception-error-value-too-long-for-type-character-varying-1000/357850 "2025-03-18T21:56:26Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Tharuni\_Subramanium](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tharuni_subramanium/32/425521_2.png) [@Tharuni\_Subramanium](https://meta.discourse.org/u/Tharuni_Subramanium)
#### Post date: [2025年三月18日 21:56 UTC](https://meta.discourse.org/t/backup-restore-fails-with-exception-error-value-too-long-for-type-character-varying-1000/357850/1 "2025-03-18T21:56:26Z")

</div>

我们正在使用 Discourse v3.2.5。

这以前是有效的，但最近我们开始遇到问题。恢复备份时，在尝试重新映射上传时会因异常 EXCEPTION: ERROR: value too long for type character varying(1000) 而失败。

[2025-03-18 21:03:24] 重新连接到数据库…

[2025-03-18 21:03:24] 重新加载站点设置…

[2025-03-18 21:03:24] 禁用非员工用户的传出邮件…

[2025-03-18 21:03:25] 禁用只读模式…

[2025-03-18 21:03:25] 清除类别缓存…

[2025-03-18 21:03:25] 重新加载翻译…

[2025-03-18 21:03:25] 重新映射上传…

[2025-03-18 21:03:27] 使用正则表达式从 ‘[//s3-bucket-name.s3.amazonaws.com/uploads/](https://s3-bucket-name.s3.amazonaws.com/uploads/)’ 重新映射到 ‘/uploads/default/’  
[2025-03-18 21:03:35] 正在恢复上传，这可能需要一段时间…  
[2025-03-18 21:03:37] 异常：错误：对于类型 character varying(1000) 的值太长

---

<div class="post-metadata">

### Author: ![Tharuni\_Subramanium](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tharuni_subramanium/32/425521_2.png) [@Tharuni\_Subramanium](https://meta.discourse.org/u/Tharuni_Subramanium)
#### Post date: [2025年三月19日 15:14 UTC](https://meta.discourse.org/t/backup-restore-fails-with-exception-error-value-too-long-for-type-character-varying-1000/357850/3 "2025-03-19T15:14:33Z")

</div>

我通过在恢复之前更改 dump.sql 中 uploads 表的 origin 列的 character varying 来修复了它。但是，我想知道它之前是如何工作的，以及为什么在数据库或应用程序没有任何更改的情况下现在会失败。我们在 3.2.1 和 3.2.5 中都看到了相同的错误。

---

<div class="post-metadata">

### Author: ![Tharuni\_Subramanium](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tharuni_subramanium/32/425521_2.png) [@Tharuni\_Subramanium](https://meta.discourse.org/u/Tharuni_Subramanium)
#### Post date: [2025年三月19日 15:22 UTC](https://meta.discourse.org/t/backup-restore-fails-with-exception-error-value-too-long-for-type-character-varying-1000/357850/4 "2025-03-19T15:22:33Z")

</div>

我发现每次访问对象时，Uploads Origin 都包含 Amazon 元数据，其中包含安全令牌。因此，长度超过了 1000。元数据包含在 Origin 中并在每次访问文件时更新的原因是什么？我们可以从 Origin URL 中删除元数据吗？或者我们可以将 character varying 约束从 1000 更新到 2000 吗？
