Last modified by Normann P. Nielsen on 2025/12/14 20:30

Hide last authors
Normann P. Nielsen 1.1 1 Install [[postgres via Docker>>https://hub.docker.com/_/postgres]] (with data in /opt/pgdata)
2
3
4 {{code}}
5 mkdir /opt/pgdata
6 docker run -d \
7 --name postgres \
8 --restart always \
9 -p 5432:5432 \
10 -e POSTGRES_PASSWORD=****** \
11 -e PGDATA=/var/lib/postgresql/data/pgdata \
12 -v /opt/pgdata:/var/lib/postgresql/data \
13 postgres
14 {{/code}}
15
16
17
18 Install the Postgres client on Ubuntu and add the User and Database
19
20
21 {{code}}
22 sudo apt-get install postgresql-client
23 psql -U postgres -h 10.0.0.183
24 {{/code}}
25
26
27
28 In the PSQL Console
29
30
31 {{code}}
32 CREATE ROLE hauser WITH LOGIN PASSWORD '******' VALID UNTIL 'infinity';
33 CREATE DATABASE homeassistant WITH ENCODING 'UTF-8' OWNER=hauser CONNECTION LIMIT=-1;
34 {{/code}}
35
36
37
38 Add the configuration to the Home Assistant secrets file
39
40
41 {{code}}
42 hadbconfig: postgresql://hauser:*****@10.0.0.183/homeassistant
43 {{/code}}
44
45
46
47 Add the config to configuration.yaml for "[[recorder>>https://www.home-assistant.io/integrations/recorder/]]"
48
49
50 {{code}}
51 recorder:
52 purge_keep_days: 30
53 db_url: !secret hadbconfig
54 {{/code}}
55
56
57
58 And restart Home Assistant