Skip to content

Instantly share code, notes, and snippets.

@cdoan1
Created June 27, 2023 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdoan1/a94e3e2d4496857316b1d299a26b8a67 to your computer and use it in GitHub Desktop.
Save cdoan1/a94e3e2d4496857316b1d299a26b8a67 to your computer and use it in GitHub Desktop.
#!/bin/bash
oc patch mch multiclusterhub -n multicluster-hub --type=merge \
-p "{\"spec\":{\"overrides\":{\"components\":[{\"name\":\"cluster-backup\",\"enabled\":true}]}}}"
oc patch mce multiclusterengine -n multicluster-engine --type=merge \
-p "{\"spec\":{\"overrides\":{\"components\":[{\"name\":\"managedserviceaccount-preview\",\"enabled\":true}]}}}"
BACKUP_NS=openshift-velero
SECRET_NAME=velero-iam-credentials
BUCKET=$(oc get backupstoragelocations.velero.io -n openshift-velero default -ojsonpath='{.spec.objectStorage.bucket}')
REGION=$(oc get backupstoragelocations.velero.io -n openshift-velero default -ojsonpath='{.spec.config.region}')
if [ -z $BUCKET ]; then
exit 1
fi
FILE=acm-dpa.yaml
FILE2=acm-schedule.yaml
cat > $FILE <<EOF
apiVersion: oadp.openshift.io/v1alpha1
kind: DataProtectionApplication
metadata:
name: acm-dpa-active
namespace: $BACKUP_NS
spec:
configuration:
restic:
enable: true
velero:
defaultPlugins:
- openshift
- aws
snapshotLocations:
- name: default
velero:
config:
profile: default
region: $REGION
provider: aws
backupLocations:
- velero:
config:
profile: default
region: $REGION
credential:
key: credentials
name: $SECRET_NAME
objectStorage:
bucket: $BUCKET
prefix: acm-backup
default: true
provider: aws
EOF
cat > $FILE2 <<EOF
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: BackupSchedule
metadata:
name: acm-schedule
namespace: $BACKUP_NS
spec:
veleroSchedule: 0 */1 * * *
veleroTtl: 12h
useManagedServiceAccount: true
EOF
oc apply -f $FILE
oc apply -f $FILE2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment