?? Automate Boot Volume Backups with Ease!

?? Automate Boot Volume Backups with Ease!

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

  • Efficient Backup Creation: Generates backups for each boot volume attached to instances.
  • Customizable: Easily adapt the script by replacing comp_id with your actual compartment ID.
  • Automated Naming: Backups are named with a timestamp to ensure clarity and organization.

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

  1. Instance Retrieval: Fetches instance details within your specified compartment.
  2. Backup Naming: Automatically names backups with a timestamp for easy identification.
  3. Script Execution: Generates OCI CLI commands to create full boot volume backups.

?? 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!

要查看或添加评论,请登录

Muzakkir Sayed的更多文章

社区洞察

其他会员也浏览了