2024-03-17 11:10:10 +00:00
|
|
|
### Postgres Ops
|
|
|
|
|
|
|
|
To access postgres use port forwarding in kubernetes
|
|
|
|
|
|
|
|
```
|
|
|
|
kubectl port-forward --address 0.0.0.0 service/oneuptime-postgresql 5432:5432
|
|
|
|
```
|
|
|
|
|
|
|
|
then you should be able to access from the localhost and port 5432
|
|
|
|
|
|
|
|
You also need to read postgres password which is stored in kubenretes secrets. You can decode the password by using this command:
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
# Username for Postgres user is `postgres`
|
2024-06-05 11:27:31 +00:00
|
|
|
echo $(kubectl get secret --namespace "default" oneuptime-postgresql -o jsonpath="{.data.postgres-password}" | base64 -d)
|
2024-03-17 11:10:10 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Important: Please ignore % in the end of the password output.
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
# Username for Postgres user is `oneuptime`
|
2024-06-05 11:27:31 +00:00
|
|
|
echo $(kubectl get secret --namespace "default" oneuptime-postgresql -o jsonpath="{.data.password}" | base64 -d)
|
2024-03-17 11:10:10 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Important: Please ignore % in the end of the password output.
|
|
|
|
|
|
|
|
|
|
|
|
This will make the database accessible from the localhost:5432.
|
|
|
|
|
|
|
|
|
|
|
|
### Postgres Backup
|
|
|
|
|
2024-03-17 11:46:32 +00:00
|
|
|
Please fill the values in config.env file and run the following command to take the backup of the database.
|
2024-03-17 11:10:10 +00:00
|
|
|
|
|
|
|
```
|
2024-03-23 20:27:32 +00:00
|
|
|
bash ./backup.sh
|
2024-03-17 11:14:36 +00:00
|
|
|
```
|
|
|
|
|
2024-03-17 11:46:32 +00:00
|
|
|
### Postgres Restore
|
2024-03-17 11:14:36 +00:00
|
|
|
|
2024-03-17 11:46:32 +00:00
|
|
|
Please fill the values in config.env file and run the following command to restore the database.
|
2024-03-17 11:14:36 +00:00
|
|
|
|
|
|
|
```
|
2024-03-23 20:27:32 +00:00
|
|
|
bash ./restore.sh
|
2024-03-17 11:14:36 +00:00
|
|
|
```
|
2024-09-18 15:38:53 +00:00
|
|
|
|
|
|
|
### Create Read Only User in Postgres (This can be used for reporting purpose like Metabase)
|
|
|
|
|
|
|
|
```
|
|
|
|
CREATE ROLE readonlyuser WITH LOGIN PASSWORD '<password>'
|
|
|
|
GRANT pg_read_all_data TO readonlyuser;
|
|
|
|
```
|
|
|
|
|
|
|
|
```
|