From a0e045940eef346fbe49980a8798b03d28cb8d23 Mon Sep 17 00:00:00 2001 From: Ruben Ruiz de Gauna Date: Wed, 8 Jan 2025 15:20:30 +0100 Subject: [PATCH] test recovery --- .github/workflows/recover_s3_repository.yml | 54 +++++++++++++-------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/.github/workflows/recover_s3_repository.yml b/.github/workflows/recover_s3_repository.yml index 819e826a2..951d3a002 100644 --- a/.github/workflows/recover_s3_repository.yml +++ b/.github/workflows/recover_s3_repository.yml @@ -1,21 +1,16 @@ name: . ⚠️⚠️⚠️ Recover S3 Repository back in time ⚠️⚠️⚠️ on: - workflow_dispatch: - inputs: - date_time: - description: 'UTC DateTime to recover the S3 repository back in time (MM-DD-YYYY HH:MM:SS +0)' - type: string - required: true - path: - description: 'Path under infrastructure_agent folder to recover (w/o leading slash, with trailing slash)' - type: string - required: true + push: + branches: + - 'NR-229418_disaster_recovery_action_TEST' env: - BUCKET: 'nr-downloads-main' - MANDATORY_PREFIX: 'infrastructure_agent/' + MANDATORY_PREFIX: '20240108-test-disaster-recovery/' IMAGE: 'ghcr.io/newrelic-forks/s3-pit-restore:latest' + DATETIME: '01-08-2025 13:22:00 +0000' + PATH: 'test1/' + ENVIRONMENT: 'staging' jobs: recover-s3-repository: @@ -24,7 +19,7 @@ jobs: steps: - name: Validate datetime run: | - datetime="${{ github.event.inputs.date_time }}" + datetime="${{ env.DATETIME }}" # Use Python's strptome (same as s3-pit-restore) to check if it's a valid datetime python3 -c "from datetime import datetime; datetime.strptime('$datetime', '%m-%d-%Y %H:%M:%S %z')" 2> /dev/null exit_code=$? @@ -35,7 +30,7 @@ jobs: - name: Validate path input does not have leading slash and has trailing slash run: | - path="${{ github.event.inputs.path }}" + path="${{ env.PATH }}" # Check if the path has a leading slash if [[ "$path" == /* ]]; then echo "Invalid path: should not have a leading slash." @@ -54,11 +49,30 @@ jobs: repository: newrelic-forks/s3-pit-restore ref: master - - name: Run S3 PIT restore +# - name: Run S3 PIT restore Production S3 +# if: ${{ github.event.inputs.environment == 'production' }} +# run: | +# BUCKET="nr-downloads-main" \ +# PREFIX="${{ env.MANDATORY_PREFIX }}${{ github.event.inputs.path }}" \ +# TIME="${{ github.event.inputs.date_time }}" \ +# IMAGE="${{ env.IMAGE }}" \ +# make validate-input +# env: +# AWS_ACCESS_KEY_ID: ${{ secrets.OHAI_AWS_ACCESS_KEY_ID_PRODUCTION }} +# AWS_SECRET_ACCESS_KEY: ${{ secrets.OHAI_AWS_SECRET_ACCESS_KEY_PRODUCTION }} +# AWS_ROLE_ARN: ${{ secrets.OHAI_AWS_ROLE_ARN_PRODUCTION }} +# AWS_ROLE_SESSION_NAME: ${{ secrets.OHAI_AWS_ROLE_SESSION_NAME_PRODUCTION }} + + - name: Run S3 PIT restore in Staging S3 + if: ${{ env.ENVIRONMENT == 'staging' }} run: | - AWS_PROFILE=primary/okta_onhostintegrations \ - BUCKET="nr-downloads-main" \ - PREFIX="${{ env.MANDATORY_PREFIX }}${{ github.event.inputs.path }}" \ - TIME="${{ github.event.inputs.date_time }}" \ + BUCKET="nr-downloads-ohai-staging" \ + PREFIX="${{ env.MANDATORY_PREFIX }}${{ env.PATH }}" \ + TIME="${{ env.DATETIME }}" \ IMAGE="${{ env.IMAGE }}" \ - make restore + make validate-input + env: + AWS_ACCESS_KEY_ID: ${{ secrets.OHAI_AWS_ACCESS_KEY_ID_STAGING }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.OHAI_AWS_SECRET_ACCESS_KEY_STAGING }} + AWS_ROLE_ARN: ${{ secrets.OHAI_AWS_ROLE_ARN_STAGING }} + AWS_ROLE_SESSION_NAME: ${{ secrets.OHAI_AWS_ROLE_SESSION_NAME_STAGING }}