|
1 |
| -#### How to sping up the db service along with disaster recovery setup. |
| 1 | +### Generating Key Pair for DB |
2 | 2 |
|
3 |
| -1. Create a clone of this repository |
4 |
| -2. Create a copy of [sample.env](./common/sample.env) file (`cp common/sample.env .env`) |
5 |
| -3. **Update the environment variables in the .env file as required** ( refer to below required environment variables) |
6 |
| -4. Create a copy of example docker-compose file (`cp docker-compose.yaml.example docker-compose.yaml`) |
7 |
| -5. Edit the docker-compose.yaml and uncomment the "db" service. |
8 |
| -6. Create a copy of example Caddyfile (`cp Caddyfile.example Caddyfile`) |
9 |
| -7. Run `make install-docker` to install docker |
10 |
| -8. Exit out of VM and re-connect to the VM to reflect the latest user changes |
11 |
| -9. Run `make setup-daemon` to configure the docker daemon |
12 |
| -10. Run `sudo make setup-webhook` to start the webhook service (use `kill -9 $(lsof -t -i:9000)` to kill any existing service on 9000 port) |
13 |
| -11. Run `make deploy` to deploy all the services |
| 3 | +1. RUN `ssh-keygen -t rsa` to generate a key pair |
| 4 | +2. Set value of `cat ~/.ssh/id_rsa | base64 -w 0` in DB_SSH_PRIVATE_KEY (change the location of private key in command if needed) |
| 5 | +3. Set value of `cat ~/.ssh/id_rsa.pub | base64 -w 0` in DB_SSH_PUBLIC_KEY (change the location of private key in command if needed) |
14 | 6 |
|
| 7 | +### Steps to follow after the db container is started (only if you have enabled barman) |
15 | 8 |
|
16 |
| -##### REQUIRED ENVIRONMENT VARIABLES IN .env FILE |
| 9 | +1. Currently the ssh server doesn't start automatically, run `docker exec -it DB_CONTAINER_ID /usr/sbin/sshd` to start the ssh server inside the db container |
17 | 10 |
|
18 |
| -``` |
19 |
| -DOMAIN_SCHEME=http |
20 |
| -DOMAIN_NAME=localdev.me |
21 |
| -ENABLE_BARMAN= |
22 |
| -BARMAN_HOST= |
23 |
| -ID_RSA= |
24 |
| -ID_RSA_PUB= |
25 |
| -POSTGRES_USER= |
26 |
| -POSTGRES_PASSWORD= |
27 |
| -``` |
28 |
| -``` |
29 |
| -1. ENABLE_BARMAN (required ) : To tell service if database needs to be configured with barman disaster recovery/ |
30 |
| -2. BARMAN_HOST (required if ENABLE_BARMAN is set to true ) : IP of barman host where data needs to be replicated. |
31 |
| -3. ID_RSA (required if ENABLE_BARMAN is set to true ) : private key of postgres user which will be stored in /var/lib/postgresql/.ssh/id_rsa. |
32 |
| -4. ID_RSA_PUB= (required if ENABLE_BARMAN is set to true ) private key of postgres user which will be stored in /var/lib/postgresql/.ssh/id_rsa_pub. |
33 |
| -5. POSTGRES_USER= (required) : User for postgres database (e.g postgres) |
34 |
| -6. POSTGRES_PASSWORD= (required) : Password for postgres database user |
35 |
| -``` |
| 11 | +### Steps to setup Barman |
36 | 12 |
|
| 13 | +1. Run `make setup-barman` to setup barman |
37 | 14 |
|
38 |
| -###### NOTE: If ENABLE_BARMAN was set to true there are three additional efforts : |
39 |
| -a) It requires a manual start of sshd service with below command. |
40 |
| -> docker exec -it CONTAINER_ID /usr/sbin/sshd |
| 15 | +> [!NOTE] |
41 | 16 |
|
42 |
| -b) Key pair needs to be generated and set the required value to .env file. Refer to below example: |
43 |
| -> ssh-keygen |
44 |
| -
|
45 |
| - Content of below command should go to ID_RSA |
46 |
| - > cat ~/.ssh/id_rsa | base64 -w 0 |
47 |
| -
|
48 |
| -Content of below command should go to ID_RSA_PUB |
49 |
| - > cat ~/.ssh/id_rsa.pub | base64 -w 0 |
50 |
| -
|
51 |
| - |
52 |
| -c) copy the public key of postgres user from container and add it in /var/lib/barman/.ssh/authorized_keys of barman server. |
53 |
| -> docker exec -it CONTAINER_ID cat /var/lib/postgresql/.ssh/id_rsa.pub |
| 17 | +> 1. We will require the public key generated here while we setup Barman |
0 commit comments