AWS EKS Backup #845
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
name: AWS EKS Backup | |
on: | |
workflow_dispatch: | |
inputs: | |
custom_backup_name: | |
description: "Custom name backup. Use separator - :" | |
required: false | |
namespaces: | |
description: "List namespaces. Use separator , :" | |
required: true | |
source_cluster: | |
description: 'Select source cluster:' | |
required: true | |
type: choice | |
options: | |
- stg | |
- prod | |
schedule: | |
- cron: 0 0 * * * | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
env: | |
BACKUP_NAME_FULL: ${{ github.run_number }}-${{ github.event.inputs.source_cluster }}---full-backup-`date +"%d-%m-%Y"` | |
BACKUP_NAME_SPECIFIC: ${{ github.run_number }}-${{ github.event.inputs.source_cluster }}---specific-backup-`date +"%d-%m-%Y"` | |
jobs: | |
backup_all_namespaces: | |
name: "Backup all namespaces on ${{ github.event.inputs.source_cluster }}" | |
if: ${{ github.event.inputs.namespaces == 'All' || github.event.schedule == '0 0 * * *' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.VELERO_ID_PROD }} | |
aws-secret-access-key: ${{ secrets.VELERO_KEY_PROD }} | |
aws-region: ${{ secrets.VELERO_REGION_PROD }} | |
if: ${{ github.event.inputs.source_cluster == 'prod' || github.event.schedule == '0 0 * * *' }} | |
- run: | | |
aws eks --region ${{ secrets.VELERO_REGION_PROD }} update-kubeconfig --kubeconfig $HOME/.kube/config_prod --name k8s-gear | |
if: ${{ github.event.inputs.source_cluster == 'prod' || github.event.schedule == '0 0 * * *' }} | |
- uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.VELERO_ID_STG }} | |
aws-secret-access-key: ${{ secrets.VELERO_KEY_STG }} | |
aws-region: ${{ secrets.VELERO_REGION_STG }} | |
if: ${{ github.event.inputs.source_cluster == 'stg' }} | |
- run: | | |
aws eks --region ${{ secrets.VELERO_REGION_STG }} update-kubeconfig --kubeconfig $HOME/.kube/config_stg --name k8s-gear-stg | |
if: ${{ github.event.inputs.source_cluster == 'stg' }} | |
- run: | | |
wget https://github.com/vmware-tanzu/velero/releases/download/v1.8.1/velero-v1.8.1-linux-amd64.tar.gz | |
tar -xvf velero*.tar.gz | |
cd ./velero-v1.8.1-linux-amd64 | |
chmod +x ./velero | |
- run: | | |
./velero backup create \ | |
${{ github.event.inputs.custom_backup_name || env.BACKUP_NAME_FULL }} \ | |
--kubeconfig $HOME/.kube/config_prod \ | |
--wait | |
working-directory: ./velero-v1.8.1-linux-amd64 | |
if: ${{ github.event.inputs.source_cluster == 'prod' || github.event.schedule == '0 0 * * *'}} | |
- run: | | |
./velero backup create \ | |
${{ github.event.inputs.custom_backup_name || env.BACKUP_NAME_FULL }} \ | |
--kubeconfig $HOME/.kube/config_stg \ | |
--wait | |
working-directory: ./velero-v1.8.1-linux-amd64 | |
if: ${{ github.event.inputs.source_cluster == 'stg' }} | |
- run: | | |
./velero backup describe ${{ github.event.inputs.custom_backup_name || env.BACKUP_NAME_FULL }} --kubeconfig $HOME/.kube/config_prod | |
working-directory: ./velero-v1.8.1-linux-amd64 | |
if: ${{ github.event.inputs.source_cluster == 'prod' || github.event.schedule == '0 0 * * *'}} | |
- run: | | |
./velero backup describe ${{ github.event.inputs.custom_backup_name || env.BACKUP_NAME_FULL }} --kubeconfig $HOME/.kube/config_stg | |
working-directory: ./velero-v1.8.1-linux-amd64 | |
if: ${{ github.event.inputs.source_cluster == 'stg' }} | |
- run: | | |
./velero backup logs ${{ github.event.inputs.custom_backup_name || env.BACKUP_NAME_FULL }} --kubeconfig $HOME/.kube/config_prod | |
working-directory: ./velero-v1.8.1-linux-amd64 | |
if: ${{ github.event.inputs.source_cluster == 'prod' || github.event.schedule == '0 0 * * *' }} | |
- run: | | |
./velero backup logs ${{ github.event.inputs.custom_backup_name || env.BACKUP_NAME_FULL }} --kubeconfig $HOME/.kube/config_stg | |
working-directory: ./velero-v1.8.1-linux-amd64 | |
if: ${{ github.event.inputs.source_cluster == 'stg' }} | |
backup_specific_namespaces: | |
name: "Backup namespaces: ${{ github.event.inputs.namespaces }} on ${{ github.event.inputs.source_cluster }}" | |
if: ${{ github.event.inputs.namespaces != 'All' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.VELERO_ID_PROD }} | |
aws-secret-access-key: ${{ secrets.VELERO_KEY_PROD }} | |
aws-region: ${{ secrets.VELERO_REGION_PROD }} | |
if: ${{ github.event.inputs.source_cluster == 'prod' }} | |
- run: | | |
aws eks --region ${{ secrets.VELERO_REGION_PROD }} update-kubeconfig --kubeconfig $HOME/.kube/config_prod --name k8s-gear | |
if: ${{ github.event.inputs.source_cluster == 'prod' }} | |
- uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.VELERO_ID_STG }} | |
aws-secret-access-key: ${{ secrets.VELERO_KEY_STG }} | |
aws-region: ${{ secrets.VELERO_REGION_STG }} | |
if: ${{ github.event.inputs.source_cluster == 'stg' }} | |
- run: | | |
aws eks --region ${{ secrets.VELERO_REGION_STG }} update-kubeconfig --kubeconfig $HOME/.kube/config_stg --name k8s-gear-stg | |
if: ${{ github.event.inputs.source_cluster == 'stg' }} | |
- run: | | |
wget https://github.com/vmware-tanzu/velero/releases/download/v1.8.1/velero-v1.8.1-linux-amd64.tar.gz | |
tar -xvf velero*.tar.gz | |
cd ./velero-v1.8.1-linux-amd64 | |
chmod +x ./velero | |
- run: | | |
./velero backup create \ | |
${{ github.event.inputs.custom_backup_name || env.BACKUP_NAME_FULL }} \ | |
--include-namespaces ${{ github.event.inputs.namespaces }} \ | |
--kubeconfig $HOME/.kube/config_prod \ | |
--wait | |
working-directory: ./velero-v1.8.1-linux-amd64 | |
if: ${{ github.event.inputs.source_cluster == 'prod' }} | |
- run: | | |
./velero backup create \ | |
${{ github.event.inputs.custom_backup_name || env.BACKUP_NAME_FULL }} \ | |
--include-namespaces ${{ github.event.inputs.namespaces }} \ | |
--kubeconfig $HOME/.kube/config_stg \ | |
--wait | |
working-directory: ./velero-v1.8.1-linux-amd64 | |
if: ${{ github.event.inputs.source_cluster == 'stg' }} | |
- run: | | |
./velero backup describe ${{ github.event.inputs.custom_backup_name || env.BACKUP_NAME_SPECIFIC }} --kubeconfig $HOME/.kube/config_prod | |
working-directory: ./velero-v1.8.1-linux-amd64 | |
if: ${{ github.event.inputs.source_cluster == 'prod' }} | |
- run: | | |
./velero backup describe ${{ github.event.inputs.custom_backup_name || env.BACKUP_NAME_SPECIFIC }} --kubeconfig $HOME/.kube/config_stg | |
working-directory: ./velero-v1.8.1-linux-amd64 | |
if: ${{ github.event.inputs.source_cluster == 'stg' }} | |
- run: | | |
./velero backup logs ${{ github.event.inputs.custom_backup_name || env.BACKUP_NAME_SPECIFIC }} --kubeconfig $HOME/.kube/config_prod | |
working-directory: ./velero-v1.8.1-linux-amd64 | |
if: ${{ github.event.inputs.source_cluster == 'prod' }} | |
- run: | | |
./velero backup logs ${{ github.event.inputs.custom_backup_name || env.BACKUP_NAME_SPECIFIC }} --kubeconfig $HOME/.kube/config_stg | |
working-directory: ./velero-v1.8.1-linux-amd64 | |
if: ${{ github.event.inputs.source_cluster == 'stg' }} |