Saturday, August 2, 2025

Automate RMAN Backup Upload to Oracle Cloud Object Storage via Pre-authenticated Request (PAR)

 

πŸ”Ή Introduction

When managing backups for Oracle databases, especially in cloud or hybrid environments, uploading RMAN backups to Oracle Cloud Object Storage is a cost-effective and scalable solution. In this blog, I’ll walk you through an easier and lightweight method—using Pre-authenticated Requests (PARs) instead of configuring the full backup module.

Ideal for:

  • One-time uploads

  • Lightweight databases

  • Automation without exposing full credentials

πŸ”Ή What is a Pre-authenticated Request (PAR)?

A PAR is a temporary URL that allows access to a specific Object Storage bucket or object without needing a user login or an API key. You can upload, download, or delete files securely with an expiry date

πŸ”Ή Use Case

✔️ You take local RMAN backups on a DB server (on-prem or OCI VM)
✔️ You want to push them to Oracle Object Storage for disaster recovery
✔️ You don’t want to configure Oracle Backup Module or DB System native integration

πŸ”Ή Step-by-Step: Create PAR and Upload RMAN Backup

 ✅ Step 1: Take Your RMAN Backup

Example RMAN command (level 0 full backup):

rman target / BACKUP DATABASE FORMAT '/u01/app/oracle/backup/rman_%U.bkp';

✅ Step 2: Create a Bucket in OCI

From the OCI Console:

  • Go to Object Storage → Buckets

  • Click Create Bucket

    • Name: rman-backups

    • Storage Tier: Standard

    • Encryption: Default

✅ Step 3: Create a Pre-authenticated Request (PAR)

Go to the bucket → Pre-authenticated Requests → Create PAR

  • Name: upload-rman-backup

  • Access Type: Permit uploads to this bucket

  • Expiration: e.g., 7 days

  • Click Create Pre-authenticated Request

You’ll get a URL like:

https://objectstorage.ap-mumbai-1.oraclecloud.com/p/PARKEY/n/namespace-string/b/rman-backups/o/

✅ Step 4: Upload Using curl or rclone

Assuming your RMAN backup is /u01/app/oracle/backup/rman_abc123.bkp:

curl -T rman_abc123.bkp "https://objectstorage.ap-mumbai-1.oraclecloud.com/p/PARKEY/n/namespace-string/b/rman-backups/o/rman_abc123.bkp"

Done! Your backup is now in OCI Object Storage.

✅ Optional: Automate the Upload in Shell Script

#!/bin/bash BACKUP_DIR="/u01/app/oracle/backup" PAR_URL="https://objectstorage.ap-mumbai-1.oraclecloud.com/p/PARKEY/n/namespace-string/b/rman-backups/o/" for file in $BACKUP_DIR/*.bkp; do filename=$(basename "$file") curl -T "$file" "${PAR_URL}${filename}" done

Schedule via cron to run after your backup job.

πŸ” Security Note

  • Never share PAR URLs publicly—they provide direct access.

  • Always set an expiration on PAR.

  • Delete the PAR once upload is completed (via Console or CLI).

πŸ’‘ Vignesh’s Tip

You can also create PARs using the OCI CLI:

oci os preauth-request create --access-type ObjectWrite --bucket-name rman-backups --name upload-rman-backup --time-expires "<RFC3339 timestamp>"

Useful for scripting and DevOps workflows.

πŸ”Ή Conclusion

Using Pre-authenticated Requests for RMAN backup uploads is a fast, secure, and flexible alternative to more complex OCI-native integrations. Whether you are an on-prem DBA or working in OCI VMs, this method helps you back up to the cloud without complexity.

Monitor Oracle Cloud Object Storage Space Usage via OCI CLI

 

πŸ”Ή 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:

oci setup config

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

oci os bucket list --compartment-id <your_compartment_ocid> --all

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):

oci os object list --bucket-name <bucket_name> --query "sum([*].size)" --raw-output

πŸ”Έ Sample Shell Script to Loop All Buckets:

#!/bin/bash COMPARTMENT_ID="<your_compartment_ocid>" BUCKETS=$(oci os bucket list --compartment-id $COMPARTMENT_ID --query "data[*].name" --raw-output) echo "Storage Report for Buckets in OCI:" echo "----------------------------------" for bucket in $BUCKETS; do SIZE=$(oci os object list --bucket-name "$bucket" --query "sum([*].size)" --raw-output) SIZE_MB=$(echo "scale=2; $SIZE / 1048576" | bc) echo "Bucket: $bucket - Size: $SIZE_MB MB" done

πŸ”Ή Step 4: Automate Storage Monitoring (Optional)

You can run the script daily and email the output:

crontab -e

Add this line to run at 8 AM daily:

0 8 * * * /home/opc/check_oci_storage.sh | mail -s "OCI Bucket Usage Report" your@email.com

πŸ”Ή 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.

Monday, July 28, 2025

Setting Up Cross-Region Replication in OCI Object Storage

 Setting Up Cross-Region Replication in OCI Object Storage

 

Setting Up Cross-Region Replication in OCI Object Storage

Disaster recovery and high availability are critical in cloud systems. Oracle Cloud Infrastructure (OCI) provides a built-in feature to automatically replicate Object Storage buckets across regions — with no custom scripting.

🌍 What is Cross-Region Replication?

Cross-region replication allows you to copy all objects from a bucket in one OCI region to another region’s bucket in real time or near-real time. This helps with:

  • Disaster recovery (DR)

  • Compliance requirements

  • Faster access from different geographies

πŸ›  How to Configure It

  1. Go to OCI Console → Object Storage → Your Bucket

  2. In the bucket details, select "Create Replication Policy"

  3. Choose:

    • Destination region

    • Target bucket

    • Optional: Replicate only objects with a specific prefix

  4. Click "Create" — that’s it!

OCI will handle the replication automatically for every new object you upload.

πŸ’‘ Use Case Example

If your primary region is Mumbai, you can replicate your data to Hyderabad for DR. In case Mumbai goes down, your data is safe and accessible in Hyderabad.

✅ Benefits

  • No custom scripts

  • Handles data replication securely and efficiently

  • Works well with lifecycle rules and archive policies

Save Cloud Costs by Archiving Old Files in OCI Object Storage

Save Cloud Costs by Archiving Old Files in OCI Object Storage

If you're storing backups, logs, or rarely accessed data in Oracle Cloud Infrastructure (OCI), you're likely using Object Storage - Standard Tier by default. But did you know you can automatically move old files to the cheaper Archive tier?

OCI’s Lifecycle Policies let you define rules that move or delete files based on age — no manual work, no scripts.

πŸ› ️ How to Archive Old Files Automatically

Here’s how to set up a simple rule:

  1. Login to the OCI Console

  2. Go to Object Storage → Your Bucket → Lifecycle Policies

  3. Click "Create Policy"

  4. Set:

    • Action: Archive

    • Condition: If object is older than 30 days

    • (Optional) Add a prefix if you only want to target certain folders

Once this is active, OCI will automatically move files older than 30 days to the Archive tier.

πŸ“‰ Why Archive Tier?

TierAccess TimeCostUse Case
StandardImmediateHigherRecent backups, hot data
ArchiveUp to 4 hrsVery lowOld backups, logs, cold data

πŸ’‘ Example Use Case

You have a bucket storing database dumps daily. With lifecycle rules, you can keep only the recent 30 days in Standard tier and archive the rest — saving storage costs without losing data.

✅ Final Tip

Pair this with another rule to delete archived files after 180 days, and you’ve built a full storage lifecycle — all automated.


Creating a Custom Backup Strategy for Oracle Databases on OCI Compute Using Object Storage

 

Introduction

While Oracle Cloud Infrastructure (OCI) offers built-in backup capabilities for Autonomous and DBCS databases, many DBAs run Oracle databases on OCI Compute (i.e., manually installed databases on VMs). For these, automated and cost-effective backups must be designed manually.

In this post, we’ll walk through how to implement a custom backup strategy using RMAN + shell scripts, and push backups to OCI Object Storage, ensuring secure, scalable, and low-cost storage of your database backups.

Why Use Object Storage for Backups?

  • Cost-effective (only pay for what you store)

  • Highly durable (99.999999999%)

  • Reduces local disk usage

  • Can be encrypted, versioned, and lifecycle-managed

  • Easily integrated with RMAN and shell scripts

Step 1: Set Up OCI Object Storage Bucket

  1. Go to OCI Console → Object Storage → Create Bucket

  2. Choose:

    • Bucket Name: db-backups-prod

    • Storage Tier: Standard

    • Visibility: Private

  3. Copy the namespace (you'll need this in the script)

Step 2: Install OCI CLI on the DB Server

curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh | bash
 
After install, configure: 

oci setup config

Provide tenancy OCID, user OCID, region, private key path, etc. 

Step 3: Create the RMAN Backup Script

rman target / <<EOF
RUN {
  ALLOCATE CHANNEL ch1 DEVICE TYPE DISK;
  BACKUP AS COMPRESSED BACKUPSET DATABASE FORMAT '/u01/backups/DB_%U.bkp';
  BACKUP CURRENT CONTROLFILE FORMAT '/u01/backups/CTL_%U.ctl';
  RELEASE CHANNEL ch1;
}
EOF

Step 4: Upload Backup Files to Object Storage

Here’s the shell script to upload all .bkp files to OCI:

#!/bin/bash

# Variables
BACKUP_DIR="/u01/backups"
BUCKET_NAME="db-backups-prod"
NAMESPACE="your_namespace"
OCI_PROFILE="DEFAULT"

# Upload all backups
for file in $BACKUP_DIR/*.bkp $BACKUP_DIR/*.ctl; do
  oci os object put -ns $NAMESPACE -bn $BUCKET_NAME --file "$file" --profile $OCI_PROFILE
done

# Optional: Delete local backups after upload
rm -f $BACKUP_DIR/*.bkp $BACKUP_DIR/*.ctl
 

Step 5: Automate with Cron 

crontab -e

# Backup and upload every night at 2 AM
0 2 * * * /home/oracle/scripts/backup_and_upload.sh

Security Best Practices

  • Use an OCI dynamic group and IAM policy if using Instance Principals.

  • Encrypt backup sets with CONFIGURE ENCRYPTION in RMAN.

  • Use Object Storage lifecycle policies to auto-expire older backups.

Conclusion

Even without Autonomous DB or DBCS, you can create a robust and scalable backup system on OCI using just RMAN, shell scripting, and Object Storage. It gives you full control, reduces costs, and meets compliance needs with proper encryption and retention.


 


 

 

Beyond No-Code: How Oracle AI Agent Studio Uses MCP, Governance, and AI-Unit Monitoring to Build Production-Ready Industry Agents

  Beyond No-Code: How Oracle AI Agent Studio Uses MCP, Governance, and AI-Unit Monitoring to Build Production-Ready Industry Agents Recentl...