Skip to content

Commit

Permalink
test recovery
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenruizdegauna committed Jan 8, 2025
1 parent 17cfd33 commit a0e0459
Showing 1 changed file with 34 additions and 20 deletions.
54 changes: 34 additions & 20 deletions .github/workflows/recover_s3_repository.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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=$?
Expand All @@ -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."
Expand All @@ -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 }}

0 comments on commit a0e0459

Please sign in to comment.