Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add media backup #2220

Merged
merged 7 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/deploy-application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,28 +87,28 @@ jobs:
cf_password: ${{ secrets.CF_PASSWORD }}
cf_org: gsa-tts-oros-fac
cf_space: ${{ env.space }}
command: cf run-task gsa-fac -k 3G -m 2G --name pg_backup --command "./backup_database.sh"
command: cf run-task gsa-fac -k 2G -m 2G --name pg_backup --command "./backup_database.sh ${{ env.space }}"

- name: Unbind backup s3 bucket from prod app
if: startsWith(github.ref, 'refs/tags/v1.')
- name: Deploy fac to cloud.gov
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 backups
cf_manifest: backend/manifests/manifest-fac.yml
cf_vars_file: backend/manifests/vars/vars-${{ env.space }}.yml
command: bin/ops/deploy.sh

- name: Deploy fac to cloud.gov
- name: Unbind backup s3 bucket from prod app
if: startsWith(github.ref, 'refs/tags/v1.')
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 }}
cf_manifest: backend/manifests/manifest-fac.yml
cf_vars_file: backend/manifests/vars/vars-${{ env.space }}.yml
command: bin/ops/deploy.sh
command: cf unbind-service gsa-fac backups

- name: Load historical data
uses: cloud-gov/cg-cli-tools@main
Expand Down
4 changes: 3 additions & 1 deletion backend/backup_database.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

echo "Environment set as: $1"
export PATH=/home/vcap/deps/0/apt/usr/lib/postgresql/15/bin:$PATH
date=$(date '+%Y-%m-%d-%H%M')
python manage.py dbbackup -o "prod-db-backup-$date.dump"
python manage.py dbbackup -o "$1-db-backup-$date.psql.bin"
python manage.py mediabackup -o "$1-media-backup-$date.tar"
27 changes: 27 additions & 0 deletions docs/dbbackups.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Database Backups

Information regarding the django utility can be found [on the documentation page](https://django-dbbackup.readthedocs.io/en/master/commands.html)
Database backups occur in the following ways:
1. Django backups
```bash
python manage.py dbbbackup
python manage.py mediabackup
```
2. Django restores
```bash
python manage.py dbrestore
python manage.py mediarestore
```
3. Backups in the prod environment occur every deployment, [before the most recent code is applied](https://github.com/GSA-TTS/FAC/blob/fd3a59287d58aec06a78d6da3b42a5def8fc9c98/.github/workflows/deploy-application.yml#L72-L100)
4. Manual steps are listed in the following document for where to catalog backups
* [Deploying](./deploying.md)
* Login via CF and tail the logs during a deployment (before it gets to deploy application stage)
* Post the most recent dbbackup and mediabackup file names in https://github.com/GSA-TTS/FAC/issues/2221
```bash
cf login -a api.fr.cloud.gov --sso
Select an org:
1. gsa-tts-oros-fac
Select a space:
5. production
cf logs gsa-fac
```
10 changes: 10 additions & 0 deletions docs/deploying.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ cf push -f manifests/manifest-dev.yml
5. Verify that the deploy steps all passed.
6. After deployment, the changes should be on https://app.fac.gov/.
7. If anything was merged directly into the `prod` branch, such as a hotfix, merge `prod` back into `main`.
8. Login via CF and tail the logs during a deployment (before it gets to deploy application stage)
```bash
cf login -a api.fr.cloud.gov --sso
Select an org:
1. gsa-tts-oros-fac
Select a space:
5. production
cf logs gsa-fac
```
9. Post the most recent dbbackup and mediabackup file names in https://github.com/GSA-TTS/FAC/issues/2221

To see more about branching and the deployment steps, see the [Branching](branching.md) page.

Expand Down