View stopec2instance.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
def GetInstanceRunning(): | |
client = boto3.client('ec2') | |
ec2_regions = [region['RegionName'] for region in client.describe_regions()['Regions']] | |
for region in ec2_regions: | |
ec2 = boto3.resource('ec2') | |
instances = ec2.instances.filter(Filters=[{'Name': 'instance-state-name', 'Values': ['running']}]) | |
return [instance.id for instance in instances] |
View velero-restore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BACKUP_NAME = wp-backup | |
velero restore create --from-backup $BACKUP_NAME |
View velero-backup-ns-wordpress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
velero backup create wp-backup --include-namespace wordpress | |
velero backup get | |
velero backup describe wp-backup |
View velero-install-1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
velero install --provider gcp --plugins velero/velero-plugin-for-gcp:v1.5.0 --bucket velero-backup --secret-file ./credentials-velero --use-volume-snapshots=true |
View velero-install
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
View velero-create-sa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
View create-bucket-cloudstorage-gcp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BUCKET=velero-backup-anandadwi | |
gsutil mb gs://$BUCKET/ | |
# verify | |
gsutil ls |
View restore-gke
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
View export-vars-backup-gke
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
View create-new-cluster-gke-2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder