Oracle Cloud Infrastructure Classic Object Storage – Cleanup Day with FTM CLI
Yesterday I decided to cleanup old Oracle Cloud Infrastructure Classic objects. There were a lot of files lying around in the Object Storage of a project from 2018. Cleaning up these files in the OCI console was no option, they can only be deleted one by one. And with over 1500 files, a bad idea. During the search for an option for Object Storage mass deletion, I found this tool: ftmcli – Object Storage Classic File Transfer Manager. The MOS note contains the script and a short manual how to use. It’s a Java based script, a perfect match for my Windows Subsytem for Linux (Ubuntu), which I often use for OCI actions.
OAC-Classic : How To Delete A Storage Container That has Multiple Objects. (Doc ID 2634021.1)
The Container List
Here is the content of my Object Storage Classic what I have to clean up – it contains five containers.
ftmcli – Installation
Over the WSL mountpoint in /mnt where you have access to your local Windows disk drives, transfer the package to the home directory and extract it.
[email protected]:~$ unzip ftmcli-v2.4.3.zip Archive: ftmcli-v2.4.3.zip creating: ftmcli-v2.4.3/ inflating: ftmcli-v2.4.3/README.txt inflating: ftmcli-v2.4.3/ftmcli.properties inflating: ftmcli-v2.4.3/ftmcli.jar
In the extracted subdirectory is a file called ftmcli.properties – there you have to set your OCI Object Storage information. Two parameters are used:
- user=<OCI login>
- rest-endpoint=<your Storage Classic Endpoint>
The Storage Classic Endpoint is visible in the Storage Classic Account tab. There is no need to set the password in the properties file. You are prompted for it when ftmcli is executed.
ftmcli – Commands
Available commands – output from ftmcli:
|upload||Upload a file or a directory to a container.|
|download||Download an object or a virtual directory from a container.|
|create-container||Create a container.|
|restore||Restore an object from an Archive container.|
|list||List containers in the account or objects in a container.|
|delete||Delete a container in the account or an object in a container.|
|describe||Describes the attributes of a container in the account or an object in a container.|
|set||Set the metadata attribute(s) of a container in the account or an object in a container.|
|set-crp||Set a replication policy for a container.|
|copy||Copy an object to a destination container.|
ftmcli – List Object Storage Containers
Here you will be prompted for your OCI password. Curious thing: My existing OCI password what I have used for months contained a lot of special characters( ,LCaOQ3|~[PT”+x), and there were not accepted.
[email protected]:~/ftmcli-v2.4.3$ java -jar ftmcli.jar list Enter your password: ERROR:Authentication failed. Authentication failure
I had to set a new OCI account password with less complexity and special characters and then it worked.
[email protected]:~/ftmcli-v2.4.3$ java -jar ftmcli.jar list Enter your password: _apaas bdcvision dbcs-vision oac-vision oracle-data-storagec-1
ftmcli – Delete Object Storage Containers
With the -f flag, the deletion of a container which contains objects can be forced. I did it for all my containers.
[email protected]:~/ftmcli-v2.4.3$ java -jar ftmcli.jar delete -f oracle-data-storagec-1 Enter your password: Container successfully deleted: oracle-data-storagec-1
And finally all containers are removed. Job successfully done!
This is what I like in Oracle Cloud Infrastructure, for a lot of problems and technical questions are a lot of scripts and tools available like this one: ftmcli. But sometimes it’s not so easy to find them.