Last active
November 17, 2023 16:58
-
-
Save jurno/cfa9ab572d2e37e07c11facc7b5409d5 to your computer and use it in GitHub Desktop.
Revisions
-
jurno revised this gist
Nov 17, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -37,5 +37,5 @@ for ID in $WORKSPACE_ID; do -H "Content-Type: application/vnd.api+json" \ "https://app.terraform.io/api/v2/workspaces/$ID/current-state-version" | jq -r '.data.attributes."hosted-state-download-url"') curl -L -H "Authorization: Bearer $TOKEN" "$OBJECT_ID" -o $BACKUP_DIR/$ID.tfstate done -
jurno revised this gist
May 22, 2022 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -11,10 +11,10 @@ if [ -z $1 ] then echo "[ERROR] Musis zadat nazov TFC organization ako parameter." echo " Napriklad: ./backup-terraform-cloud.sh azure-sandbox-pd" echo "" exit 1 fi TOKEN=$(cat ~/.terraform.d/credentials.tfrc.json | jq -r '.[]."app.terraform.io".token') -
jurno revised this gist
May 22, 2022 . 1 changed file with 9 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,14 @@ #!/bin/bash # Odzalohuje vsetky statefiles z organization v Terraform Cloud. Skript predpoklada, # ze pouzivatel je prihlaseny do Terraform Cloud cez `terraform login` a takto ziskany # token ma ulozeny defaultnym sposobom. # https://www.terraform.io/cli/commands/login#credentials-storage # Pouzitie: # chmod +x ./backup-terraform-cloud.sh # ./backup-terraform-cloud.sh <ORGANIZATION> if [ -z $1 ] then echo "[ERROR] Musis zadat nazov TFC organization ako parameter." -
jurno revised this gist
May 22, 2022 . 1 changed file with 10 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,19 @@ #!/bin/bash if [ -z $1 ] then echo "[ERROR] Musis zadat nazov TFC organization ako parameter." echo " Napriklad: ./backup-terraform-cloud.sh azure-sandbox-pd" echo "" exit 1 fi TOKEN=$(cat ~/.terraform.d/credentials.tfrc.json | jq -r '.[]."app.terraform.io".token') ORG_NAME=$1 YEAR=$(date +"%Y") MONTH=$(date +"%m") DIR=$(date +"%y%m%d-%H%M") BACKUP_DIR=$YEAR/$MONTH/$DIR/$ORG_NAME mkdir -p $BACKUP_DIR -
jurno revised this gist
Apr 3, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #!/bin/bash TOKEN=$(cat ~/.terraform.d/credentials.tfrc.json | jq -r '.[]."app.terraform.io".token') ORG_NAME=azure-sandbox-pd YEAR=$(date +"%Y") MONTH=$(date +"%m") -
jurno revised this gist
Mar 19, 2022 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,10 @@ TOKEN= ORG_NAME=azure-sandbox-pd YEAR=$(date +"%Y") MONTH=$(date +"%m") DIR=$(date +"%y%m%d-%H%M") BACKUP_DIR=$YEAR/$MONTH/$DIR mkdir -p $BACKUP_DIR -
jurno created this gist
Mar 18, 2022 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ #!/bin/bash TOKEN= ORG_NAME=azure-sandbox-pd BACKUP_DIR=$(date +"%y%m%d-%H%M") mkdir -p $BACKUP_DIR WORKSPACE_ID=$(curl \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/vnd.api+json" \ "https://app.terraform.io/api/v2/organizations/$ORG_NAME/workspaces" | jq -r '.data [].id') for ID in $WORKSPACE_ID; do OBJECT_ID=$(curl \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/vnd.api+json" \ "https://app.terraform.io/api/v2/workspaces/$ID/current-state-version" | jq -r '.data.attributes."hosted-state-download-url"') curl -H "Authorization: Bearer $TOKEN" "$OBJECT_ID" -o $BACKUP_DIR/$ID.tfstate done