# 如何将我的 s3 上传存储桶从一个提供商迁移到另一个提供商？

**URL:** https://meta.discourse.org/t/how-do-i-move-my-s3-upload-bucket-from-one-provider-to-another/178484
**Category:** Support
**Created:** [2021年二月5日 00:06 UTC](https://meta.discourse.org/t/how-do-i-move-my-s3-upload-bucket-from-one-provider-to-another/178484 "2021-02-05T00:06:53Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![seeminglee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/seeminglee/32/199310_2.png) [@seeminglee](https://meta.discourse.org/u/seeminglee)
#### Post date: [2021年二月5日 00:06 UTC](https://meta.discourse.org/t/how-do-i-move-my-s3-upload-bucket-from-one-provider-to-another/178484/1 "2021-02-05T00:06:53Z")

</div>

我最初在 AWS 上设置了上传存储桶，但现在想改用 Linode。设置过程顺利，我已确认图片正在上传到 Linode。

不过，查看旧帖子时发现，它们仍然指向 AWS。我该如何将这些图片迁移到 Linode，以便删除 AWS 上的存储桶？

谢谢！

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2021年二月5日 00:08 UTC](https://meta.discourse.org/t/how-do-i-move-my-s3-upload-bucket-from-one-provider-to-another/178484/2 "2021-02-05T00:08:14Z")

</div>

首先使用能够执行此操作的软件（如 aws cli、s3cmd 等）同步存储桶，然后执行[替换所有帖子中的字符串](https://meta.discourse.org/t/replace-a-string-in-all-posts/48729)。

---

<div class="post-metadata">

### Author: ![seeminglee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/seeminglee/32/199310_2.png) [@seeminglee](https://meta.discourse.org/u/seeminglee)
#### Post date: [2021年二月5日 01:03 UTC](https://meta.discourse.org/t/how-do-i-move-my-s3-upload-bucket-from-one-provider-to-another/178484/4 "2021-02-05T01:03:09Z")

</div>

我刚运行了以下命令：

```plaintext
rake posts:remap["https://royaleapi-discuss-uploads.s3.dualstack.ap-northeast-1.amazonaws.com/","https://royaleapi-discuss-upload.ap-south-1.linodeobjects.com/"]

```

但提示“0 posts remapped”（0 篇文章已重映射）。

尽管我确认 URL 是正确的，例如查看这里的图片链接：

[https://discuss.royaleapi.com/t/idea-for-season-21-the-archers-time/320](https://discuss.royaleapi.com/t/idea-for-season-21-the-archers-time/320)

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2021年二月5日 01:05 UTC](https://meta.discourse.org/t/how-do-i-move-my-s3-upload-bucket-from-one-provider-to-another/178484/5 "2021-02-05T01:05:34Z")

</div>

尝试

```plaintext
rake posts:remap["//royaleapi-discuss-uploads.s3.dualstack.ap-northeast-1.amazonaws.com/","//royaleapi-discuss-upload.ap-south-1.linodeobjects.com/"]

```

---

<div class="post-metadata">

### Author: ![seeminglee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/seeminglee/32/199310_2.png) [@seeminglee](https://meta.discourse.org/u/seeminglee)
#### Post date: [2021年二月5日 09:55 UTC](https://meta.discourse.org/t/how-do-i-move-my-s3-upload-bucket-from-one-provider-to-another/178484/6 "2021-02-05T09:55:28Z")

</div>

尝试了您的建议。还试了

```plaintext
rake posts:remap["royaleapi-discuss-uploads.s3.dualstack.ap-northeast-1.amazonaws.com","royaleapi-discuss-upload.ap-south-1.linodeobjects.com"]

```

结果相同：

```plaintext
正在重映射

0 篇帖子已重映射！

```

是否有其他命令可以查找所有未执行任何替换的帖子，以确认该命令能否找到有效的匹配项？

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2021年二月5日 13:35 UTC](https://meta.discourse.org/t/how-do-i-move-my-s3-upload-bucket-from-one-provider-to-another/178484/7 "2021-02-05T13:35:47Z")

</div>

你想检查 Upload 对象：

```plaintext
cd /var/discourse
./launcher enter app
rails c
Upload.order(Arel.sql('RANDOM()')).limit(10).pluck(:id, :url)

```

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [2021年二月5日 13:48 UTC](https://meta.discourse.org/t/how-do-i-move-my-s3-upload-bucket-from-one-provider-to-another/178484/8 "2021-02-05T13:48:16Z")

</div>

很好的问题和建议。是否应该标记为#操作指南？

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2021年三月7日 13:48 UTC](https://meta.discourse.org/t/how-do-i-move-my-s3-upload-bucket-from-one-provider-to-another/178484/9 "2021-03-07T13:48:56Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
