Zi 字媒體
2017-07-25T20:27:27+00:00
How to Transfer the Region of S3 Bucket from A to B
aws-cli: 2.2.20
有些時候,我們會因為成本或其他考量,需要將 S3 從 A region 遷移到 B region。
但很不幸的是,S3 是不能這樣直接轉移 region 的,因此我們必須手動自行搬移。
Usage
假設是要將 test 這個 S3 Bucket 從 ap-northeast-1 搬往 us-west-2,需要執行以下步驟:
1. 先在 us-west-2 Create 出一個 tmp Bucket。
2. 將 ap-northeast-1 的 test 資料 sync 到 us-west-2 的 tmp。
# 資料 sync
aws s3 sync s3://test s3://tmp --source-region ap-northeast-1 --region us-west-2
# 透過 rb 指令移除 test Bucket 和資料
aws s3 rb s3://test --force
這邊要注意的是,在這一個步驟上有可能會遇到 無法刪除 Bucket 的問題,原因是如果有在 Bucket 上設定 lifecycle_rule 的話,一些上傳失敗的檔案會卡在暫存裡,沒有清掉就不能刪除 Bucket。
解決方法有兩種可以選:
到後台的 S3 Bucket List 頁面,選取該 Bucket,並且選擇 Empty 清空以後就可以刪除了。
使用 aws s3 rm s3://bucket-name --recursive 指令。可以參考 官方文件。
3. 在 us-west-2 Create 出一個 test Bucket。
Notice: 雖然 S3 Bucket 有分 region,但是 Bucket name 是 global 共用的,因此當我們刪除 test 以後,必須 AWS 都同步完了,才可以建出同名的 S3 Bucket。可以參考 官方文件。
4. 將 us-west-2 的 tmp sync 到 us-west-2 的 test
# 資料 sync
aws s3 sync s3://tmp s3://test --source-region us-west-2 --region us-west-2
# 透過 rb 指令移除 tmp Bucket 和資料
aws s3 rb s3://tmp --force
Categories: AWS
Tags: AWSS3
分類
Android
AngularJS
API Blueprint
Chrome
Cloud-Solution
AWS
Azure
Database
MySQL
DataStructure
Docker
Editor
Vim
Firefox
Git
GitLab
Google API
Hadoop
HTTP
Language
Go
Java
JavaScript
jQuery
jQueryChart
Node.js
Vue
Vue-CLI
PHP
Laravel
Lumen
ZendFramework
Python
Mac
Network
Cisco
DLink
Juniper
Oauth
Server
Apache
Share
Unix
FreeBSD
Linux
WebDesign
Bootstrap
CSS
HTML
Wordpress
Search
搜尋關鍵字:
寫了
5860316篇文章,獲得
23313次喜歡