Skip to content

Commit f6eb666

Browse files
authored
Merge pull request #335 from OperationCode/document-backups
Add instructions for manual DB backups
2 parents ac1cf02 + 414bc70 commit f6eb666

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Ops.md

+17
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,20 @@ open https://localhost:8443
1818
- Validate the staging environment (try a few API calls, particularly GET and POST)
1919
4. Repeat those steps for the production environment
2020
- When validating prod, please add a real resource to the API, not a test resource (there's no way to delete a test resource using the API)
21+
22+
# Backing up prod to staging
23+
24+
Every so often, we should back up prod to staging to ensure that we don't lose data, and also so that the staging data isn't stale during testing. And also, to blow away test changes that were made to staging while validating a new image version before going to prod.
25+
26+
1. Create a postgres image in the cluster
27+
```bash
28+
kubectl run -it postgres --image postgres:9.6 --rm -- /bin/bash
29+
```
30+
2. Run the following command to dump the resources data (replace username and dbname with the values in resources-api-secrets). You'll be prompted for the db password, so have that value ready as well.
31+
```bash
32+
pg_dump --clean --if-exists --inserts --quote-all-identifiers --host=python-prod.czwauqf3tjaz.us-east-2.rds.amazonaws.com --username=XXXX --dbname=XXX -f prod_backup.sql
33+
```
34+
3. Restore the data to staging with this command (have the password for staging db at the ready, because again, you'll be prompted for it)
35+
```bash
36+
psql --host=python-staging.czwauqf3tjaz.us-east-2.rds.amazonaws.com --username=XXXX --dbname=XXXX -f prod_backup.sql
37+
```

0 commit comments

Comments
 (0)