?? Automate Boot Volume Backups with Ease!
Muzakkir Sayed
Cloud Architect & Advisor - Designing, Implementing Cloud Solutions | OCI, AWS, Azure | Python, DevOps, Terraform | Kubernetes & Dockers
?? Excited to share a time-saving script for creating boot volume backups across your Oracle Cloud Infrastructure instances!
Are you managing multiple instances in Oracle Cloud Infrastructure? Simplify your backup strategy with this script that automates the creation of boot volume backups for all instances in your compartment.
Key Features:
领英推荐
#Proprietary Claim: Owned by Sayed Muzakkir Haafiz, Cloud Architect, Automation #Expert.
#!/bin/bash
comp_id=<Compartment_ID>
# Function to get current date and month in DDMON format
get_ddmon() {
date +"%d%b"
}
# Step 1: Get the OCIDs of instances in the compartment and store them in a #temporary file
oci compute instance list --compartment-id "$comp_id" --all --query "data[*].[\"availability-domain\", \"id\"]" --raw-output | jq -r '.[] | @csv' | sed 's/"https://g' > instance_details.csv
# Clear the contents of the file before appending new content
> create_boot_volume_backups.sh
# Loop through each line in instance_details.csv
while IFS=, read -r availability_domain instance_id; do
# Generate display_name with _BootVolBkp_DDMON appended
display_name=$(oci compute instance get --instance-id "$instance_id" --query 'data."display-name"' --raw-output)
display_name="${display_name}_BootVolBkp_$(get_ddmon)"
# Generate boot_volume_id
boot_volume_id=$(oci compute boot-volume-attachment list --compartment-id "$comp_id" --availability-domain "$availability_domain" --instance-id "$instance_id" | jq -r '.data[] | .["boot-volume-id"]')
# Append OCI CLI command to create boot volume backup to the file
echo "oci bv boot-volume-backup create --boot-volume-id $boot_volume_id --display-name $display_name --type FULL" >> create_boot_volume_backups.sh
done < instance_details.csv
How It Works:
?? Get Started: Replace comp_id with your actual compartment ID and run the script to streamline your backup workflow!
Ready to enhance your cloud operations? Download and adapt this script today!