Perform Media and Database Backups #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
--- | |
name: Perform Media and Database Backups | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
required: true | |
type: string | |
jobs: | |
backup-media: | |
if: ${{ inputs.environment == 'dev' }} | |
name: Perform Media Backups | |
runs-on: ubuntu-latest | |
environment: ${{ inputs.environment }} | |
env: | |
space: ${{ inputs.environment }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Unbind the private s3 bucket | |
uses: cloud-gov/cg-cli-tools@main | |
with: | |
cf_username: ${{ secrets.CF_USERNAME }} | |
cf_password: ${{ secrets.CF_PASSWORD }} | |
cf_org: gsa-tts-oros-fac | |
cf_space: ${{ env.space }} | |
command: cf unbind-service gsa-fac fac-private-s3 | |
- name: Rebind the private s3 bucket with backups bucket as an additional instance | |
uses: cloud-gov/cg-cli-tools@main | |
with: | |
cf_username: ${{ secrets.CF_USERNAME }} | |
cf_password: ${{ secrets.CF_PASSWORD }} | |
cf_org: gsa-tts-oros-fac | |
cf_space: ${{ env.space }} | |
command: | | |
cf bind-service gsa-fac fac-private-s3 -c '{"additional_instances": ["backups"]}' | |
- name: Restart the app | |
uses: cloud-gov/cg-cli-tools@main | |
with: | |
cf_username: ${{ secrets.CF_USERNAME }} | |
cf_password: ${{ secrets.CF_PASSWORD }} | |
cf_org: gsa-tts-oros-fac | |
cf_space: ${{ env.space }} | |
command: cf restart gsa-fac | |
- name: Backup media files | |
uses: cloud-gov/cg-cli-tools@main | |
with: | |
cf_username: ${{ secrets.CF_USERNAME }} | |
cf_password: ${{ secrets.CF_PASSWORD }} | |
cf_org: gsa-tts-oros-fac | |
cf_space: ${{ env.space }} | |
command: cf run-task gsa-fac -k 2G -m 2G --name media_backup --command "./s3-sync.sh" | |
backup-dev-database: | |
if: ${{ inputs.environment == 'dev' }} | |
name: Perform Dev Database Backups | |
runs-on: ubuntu-latest | |
environment: ${{ inputs.environment }} | |
env: | |
space: ${{ inputs.environment }} | |
steps: | |
- name: Backup Dev Database | |
uses: cloud-gov/cg-cli-tools@main | |
with: | |
cf_username: ${{ secrets.CF_USERNAME }} | |
cf_password: ${{ secrets.CF_PASSWORD }} | |
cf_org: gsa-tts-oros-fac | |
cf_space: ${{ env.space }} | |
command: cf run-task gsa-fac -k 2G -m 2G --name pg_backup --command "./backup_database.sh ${{ env.space }}" | |
# backup-prod-database: | |
# if: ${{ inputs.environment == 'production' }} | |
# name: Perform Prod Database Backups | |
# runs-on: ubuntu-latest | |
# environment: ${{ inputs.environment }} | |
# env: | |
# space: ${{ inputs.environment }} | |
# steps: | |
# - name: Bind backup s3 bucket to prod app | |
# uses: cloud-gov/cg-cli-tools@main | |
# with: | |
# cf_username: ${{ secrets.CF_USERNAME }} | |
# cf_password: ${{ secrets.CF_PASSWORD }} | |
# cf_org: gsa-tts-oros-fac | |
# cf_space: ${{ env.space }} | |
# command: cf bind-service gsa-fac backups -w | |
# - name: Backup the database (Prod Only) | |
# uses: cloud-gov/cg-cli-tools@main | |
# with: | |
# cf_username: ${{ secrets.CF_USERNAME }} | |
# cf_password: ${{ secrets.CF_PASSWORD }} | |
# cf_org: gsa-tts-oros-fac | |
# cf_space: ${{ env.space }} | |
# command: cf run-task gsa-fac -k 2G -m 2G --name pg_backup --command "./backup_database.sh ${{ env.space }}" | |