To get Availability Domain
oci iam availability-domain list
#!/bin/bash
OCI_AD="hQsi:SA-SAOPAULO-1-AD-1"
OCI_COMPARTMENT="ocid1.compartment.oc1..aaaaaaaavgyjpoffz5qliieawamjaksfb6juxejurtduclqjkvv66ookcxja"
#Get Silver policy ocid
funct_get_policy(){
OCI_POL_OCID=$(oci bv volume-backup-policy list | jq -r '.data[] | select(."display-name"|contains("silver"))' | jq -r '.id')
}
funct_boot_vol (){
#Create a file with all boot volume ocid
oci bv boot-volume list --availability-domain ${OCI_AD} -c ${OCI_COMPARTMENT} | jq -r '.data[].id' > boot-vol.txt
while IFS="" read -r p || [ -n "$p" ]
do
printf 'Seeting backup policy for %s\n' "$p"
oci bv volume-backup-policy-assignment create --asset-id $p --policy-id ${OCI_POL_OCID}
done < boot-vol.txt
}
funct_block_vol (){
#Create a file with all block volume ocid
oci bv volume list -c ${OCI_COMPARTMENT} | jq -r '.data[].id' > block-vol.txt
while IFS="" read -r p || [ -n "$p" ]
do
printf 'Seeting backup policy for %s\n' "$p"
oci bv volume-backup-policy-assignment create --asset-id $p --policy-id ${OCI_POL_OCID}
done < block-vol.txt
}
Comentários
Postar um comentário