๐น Introduction
Managing storage efficiently is essential, especially when dealing with large backups or logs in Oracle Cloud Infrastructure (OCI). While the OCI Console provides visibility, it’s not always ideal for scripting or automation. In this post, we’ll explore how to use the OCI Command Line Interface (CLI) to monitor the space usage of your Object Storage buckets.
๐น What You’ll Learn
-
How to install and configure OCI CLI
-
List all buckets in a compartment
-
Retrieve storage usage details per bucket
-
Generate a summary report
Optional: Automate and send email alerts
๐น Step 1: Install & Configure OCI CLI
If you haven’t already installed the CLI:
bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)"
After installation, run:
You'll be prompted to enter:
-
Tenancy OCID
-
User OCID
-
Compartment OCID
-
Region
API key (which it generates)
๐น Step 2: List Buckets in Your Compartment
Output will show all buckets, their names, and creation timestamps.
๐น Step 3: Check Storage Usage per Bucket
To get the total size of a bucket (in bytes):
๐ธ Sample Shell Script to Loop All Buckets:
๐น Step 4: Automate Storage Monitoring (Optional)
You can run the script daily and email the output:
Add this line to run at 8 AM daily:
๐น Tips for DBAs
-
Use Storage Class filters (Standard vs Archive) to reduce costs.
-
Enable Lifecycle Policies to auto-delete old files.
Avoid keeping RMAN backups longer than needed.
๐น Vignesh’s Tip
For temporary one-time uploads (like logs or exported tables), use Pre-Authenticated Requests (PARs). They give you a URL without needing to expose keys or public access.
๐น Conclusion
Monitoring storage usage with OCI CLI not only helps you manage cost but also keeps your backup strategy efficient. For DBAs and DevOps engineers working in hybrid environments, this approach enables easy scripting and reporting.
No comments:
Post a Comment