Skip to content

Commit c4afa22

Browse files
authored
Merge pull request #227 from mapswipe/docs
Add backup restore section and contribution guidelines
2 parents 8f39aa2 + 22265be commit c4afa22

File tree

2 files changed

+51
-9
lines changed

2 files changed

+51
-9
lines changed

docs/source/backup.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,19 @@ The WAL-G backup setup is integrated into the Postgres Docker image. It will do
1414
WAL-G is installed alongside Postgres. See the Dockerfile of Postgres (`postgres/Dockerfile`) for details. In the docker-compose postgres command (`docker-compose.yml`) archive parameter of postgres are set needed to make archives.
1515

1616

17-
## Restore setup
17+
### Configuration
1818

19-
The WAL-G restore setup is realized in a dedicated Docker image (`postgres/Dockerfile-restore_backup`). It will create a new Postgres database cluster, fetch latest backup using `wal-g backup-fetch` and create a `recovery.conf` file in the new cluster during Docker build. `recovery.conf` is used by Postgres during first start to get the `restore_command`. Again the exact commands are to be found in `postgres/wal-g/restore_command.sh`. During first start Postgres will get WALs from backup server and restore the database.
19+
To store backups in Google Cloud Storage, WAL-G requires that this variable is set: `WALG_GS_PREFIX` to specify where to store backups (eg. `gs://x4m-test-bucket/walg-folder`).
20+
Please add this to the `.env` file at the root of MapSwipe Back-end (See `.example-env` for environment variables which have to be set)
2021

22+
WAL-G determines Google Cloud credentials using application-default credentials like other GCP tools. Get a Service Account Key file (`serviceAccountKey.json`) for your Google Cloud Storage (See [Google Cloud Docs](https://cloud.google.com/iam/docs/creating-managing-service-account-keys)) and save it to `postgres/serviceAccountKey.json`.
2123

22-
## Configuration
2324

24-
To store backups in Google Cloud Storage, WAL-G requires that this variable be set: `WALG_GS_PREFIX` to specify where to store backups (eg. `gs://x4m-test-bucket/walg-folder`).
25-
Please add this to your `.env` file at the root of MapSwipe Back-end (See `.example-env` for environment variables wich needs to be set)
25+
## Restore setup
2626

27-
WAL-G determines Google Cloud credentials using application-default credentials like other GCP tools. Get a Service Account Key file (`serviceAccountKey.json`) for your Google Cloud Storage (See [Google Cloud Docs](https://cloud.google.com/iam/docs/creating-managing-service-account-keys)) and save it to `postgres/serviceAccountKey.json`.
27+
The WAL-G restore setup is realized in a dedicated Docker image (`postgres/recovery/Dockerfile`). The entrypoint is the `ini_recovery.sh` srcipt. This script will create a new Postgres database cluster, fetch latest backup using `wal-g backup-fetch` and create a `recovery.conf` file in the new cluster. `recovery.conf` is used by Postgres during first start to get the `restore_command`. Again the exact commands are to be found in `postgres/recovery/restore_command.sh`. During first start Postgres will get WALs from backup server and restore the database.
28+
29+
30+
### Configuration
31+
32+
> The same configuration as for the backup setup is requiered. Except the Service Account Key has to be stored at `postgres/recovery/serviceAccountKey`.

docs/source/contributing.md

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,49 @@
11
# Contributing
22

3-
This document is a work progress. It should describe how to contribute (code or issues) to the MapSwipe back-end.
43

5-
To contribute to the MapSwipe back-end please create dedicated feature branches.
4+
## Clone from GitHub
65

76
```bash
7+
git clone https://github.com/mapswipe/python-mapswipe-workers.git
8+
cd python-mapswipe-workers
9+
git checkout dev
10+
```
11+
12+
13+
## Install MapSwipe Workers
14+
15+
Create a Python virtual environment and activate it. Install MapSwipe Workers using pip:
16+
17+
```bash
18+
python -m venv venv
19+
source venv/bin/activate
20+
pip install --editable .
21+
```
22+
23+
24+
## Feature Branch
25+
26+
To contribute to the MapSwipe back-end please create dedicated feature branches from dev:
27+
28+
```bash
29+
git checkout dev
830
git checkout -b featureA
931
git commit -am 'add new project type'
1032
git push -u origin featureA
11-
git request-pull origin/master featureA
33+
git request-pull origin/dev featureA
34+
```
35+
36+
> Note: If a bug in production (master branch) needs fixing before a new versions of MapSwipe Workers gets released (merging dev into master branch), a hotfix branch should be created. In the hotfix branch the bug should be fixed and then merged back with master and also dev.
37+
38+
39+
## Style Guide
40+
41+
This project uses [black](https://github.com/psf/black) and [flake8](https://gitlab.com/pycqa/flake8) to achieve a unified style.
42+
43+
Use [pre-commit](https://pre-commit.com/) to run `black` and `flake8` prior to any git commit. `pre-commit`, `black` and `flake8` should already be installed in your virtual environment since they are listed in `requirements.txt`. To setup pre-commit simply run:
44+
1245
```
46+
pre-commit install
47+
```
48+
49+
From now on `black` and `flake8` should run automatically whenever `git commit` is executed.

0 commit comments

Comments
 (0)