Skip to content

Instantly share code, notes, and snippets.

View misskecupbung's full-sized avatar
💤
Thinking ...

Ananda Dwi Ae misskecupbung

💤
Thinking ...
View GitHub Profile
velero backup create wp-backup --include-namespace wordpress
velero backup get
velero backup describe wp-backup
velero install --provider gcp --plugins velero/velero-plugin-for-gcp:v1.5.0 --bucket velero-backup --secret-file ./credentials-velero --use-volume-snapshots=true
wget -c https://github.com/vmware-tanzu/velero/releases/download/v1.9.2/<RELEASE-TARBALL-NAME>.tar.gz
tar -xvf <RELEASE-TARBALL-NAME>.tar.gz
sudo cp <RELEASE-TARBALL-NAME>/velero /usr/bin/
gcloud iam service-accounts create velero-backup-anandadwi --display-name "Velero SA"
SERVICE_ACCOUNT_EMAIL=$(gcloud iam service-accounts list --filter="displayName:Velero SA" --format 'value(email)')
gcloud iam service-accounts list
ROLE_PERMISSIONS=(
compute.disks.get
compute.disks.create
compute.disks.createSnapshot
compute.snapshots.get
compute.snapshots.create
BUCKET=velero-backup-anandadwi
gsutil mb gs://$BUCKET/
# verify
gsutil ls
export RESTORE="manual-restore1"
gcloud alpha container backup-restore restores create $RESTORE \
--project=$PROJECT_ID \
--location=$GCP_REGION \
--restore-plan=$RESTORE_PLAN \
--backup=projects/$PROJECT_ID/locations/$LOCATION/backupPlans/$BACKUP_PLAN/backups/$BACKUP \
--wait-for-completion
export RESTORE_LOCATION="us-central1"
export RESTORE_PLAN="gke-central1-b-restore"
export CLUSTER2="projects/$PROJECT_ID/locations/$GCP_REGION/clusters/$CLUSTER_NAME2"
export CLUSTER_RESOURCE_CONFLICT_POLICY="use-backup-version"
export NAMESPACED_RESOURCE_RESTORE_MODE="delete-and-restore"
export VOLUME_DATA_RESTORE_POLICY="restore-volume-data-from-backup"
export CLUSTER_NAME2="gke-central1-b"
gcloud beta container clusters create $CLUSTER_NAME2 \
--project=$PROJECT_ID \
--region=$LOCATION \
--addons=BackupRestore \
--num-nodes=1 \
--enable-autoupgrade --no-enable-basic-auth \
--no-issue-client-certificate --enable-ip-alias \
--metadata disable-legacy-endpoints=true \
--workload-pool=$IDNS
export BACKUP=manual-backup1
gcloud alpha container backup-restore backups create $BACKUP \
--project=$PROJECT_ID \
--location=$LOCATION \
--backup-plan=$BACKUP_PLAN \
--wait-for-completion
gcloud alpha container backup-restore backup-plans create $BACKUP_PLAN \
--project=$PROJECT_ID \
--location=$LOCATION \
--cluster=$CLUSTER \
--all-namespaces \
--include-secrets \
--include-volume-data \
--cron-schedule="0 * * * *" \
--backup-retain-days=$RETAIN_DAYS \
--locked