LoginSignup
2
0

IBM Cloud: ICOS上のデータを再帰的に一括で削除する方法

Last updated at Posted at 2024-05-09

1. はじめに

ICOS(IBM Cloud Object Storage)のようなオブジェクトストレージにおいて、データをまとめて削除する方法の紹介。

  • バケットを削除しようと思った

  • →バケットの中身が全部消えていないと削除できない。image.png

  • →バケットの中身を消していこうと思っても、下の階層にあるオブジェクトを削除できないので、どんどん下に潜っていく必要がある(フォルダを削除するためには、フォルダの中にあるファイルを先に消す必要があるようなもの)。数が多くて手動では無理・・・

という事態を避ける際に利用する。

2. 方法

Emptying a bucketに紹介されている。要は、例えばaws CLIであれば

aws --endpoint-url https://s3.direct.jp-tok.cloud-object-storage.appdomain.cloud s3 rm s3://{bucket-name}/xxxx --recursive

のようにやってやれば良い。

3. 実例

今回は、OnVUE.appおよびVeeamを丸ごと削除する。

bucket一覧
$ aws --endpoint-url https://s3.direct.jp-tok.cloud-object-storage.appdomain.cloud s3 ls s3://mybucketxxx
                           PRE OnVUE.app/
                           PRE Veeam/
2022-07-21 09:02:53        195 error.html
2022-07-21 09:02:53      65235 favicon.ico
2022-08-20 09:26:43          7 hello.txt
2022-07-21 09:02:53        284 index.html
2022-07-21 09:02:53      24237 ninja.jpg
2022-07-21 09:02:54        423 sorry.html
OnVUE.appの削除
$ aws --endpoint-url https://s3.direct.jp-tok.cloud-object-storage.appdomain.cloud s3 rm --recursive s3://mybucketxxx/OnVUE.app/
delete: s3://mybucketxxx/OnVUE.app/Contents/Frameworks/Electron Framework.framework/Resources/
delete: s3://mybucketxxx/OnVUE.app/Contents/Frameworks/Electron Framework.framework/Resources/en.lproj/
delete: s3://mybucketxxx/OnVUE.app/Contents/Frameworks/
(途中略)
Veeamの削除
$ aws --endpoint-url https://s3.direct.jp-tok.cloud-object-storage.appdomain.cloud s3 rm --recursive s3://mybucketxxx/Veeam
delete: s3://mybucketxxx/Veeam/Archive/backup/
delete: s3://mybucketxxx/Veeam/Archive/
delete: s3://mybucketxxx/Veeam/
(途中略)
無事消えてくれた
$ aws --endpoint-url https://s3.direct.jp-tok.cloud-object-storage.appdomain.cloud s3 ls s3://mybucketxxx
2022-07-21 09:02:53        195 error.html
2022-07-21 09:02:53      65235 favicon.ico
2022-08-20 09:26:43          7 hello.txt
2022-07-21 09:02:53        284 index.html
2022-07-21 09:02:53      24237 ninja.jpg
2022-07-21 09:02:54        423 sorry.html
2
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0