-
Notifications
You must be signed in to change notification settings - Fork 15
/
trmmdockerpostgresupdate.txt
105 lines (47 loc) · 2.21 KB
/
trmmdockerpostgresupdate.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
### Find tacticalrmm postgres volume
sudo docker volume ls
### Copy mountpoint info
sudo docker volume inspect tacticalrmm_postgres_data
"Mountpoint": "/path/to/docker/volumes/tacticalrmm_postgres_data/_data"
### Stop tactical containers
### Dump database
sudo docker run -d --name=temppostgres -e POSTGRES_USER=tactical -e POSTGRES_PASSWORD=password -e POSTGRES_DB=tacticalrmm -v /path/to/docker/volumes/tacticalrmm_postgres_data/_data:/var/lib/postgresql/data postgres:13-alpine
sudo docker exec -it temppostgres bash
pg_dump -U tactical -d tacticalrmm > /var/lib/postgresql/data/dump.sql
exit
### Backup postgres volume using parent folder
sudo cp -R /path/to/docker/volumes/tacticalrmm_postgres_data/ /path/to/docker/volumes/tacticalrmm_postgres_data_backup
### Stop old container and remove it
sudo docker stop temppostgres
sudo docker rm temppostgres
### Delete old volume
sudo rm -rf /path/to/docker/volumes/tacticalrmm_postgres_data
### Pull new image
sudo docker pull postgres:14-alpine
### start postgres14 container
sudo docker run -d --name=temppostgres -e POSTGRES_USER=tactical -e POSTGRES_PASSWORD=password -e POSTGRES_DB=tacticalrmm -v /path/to/docker/volumes/tacticalrmm_postgres_data/_data:/var/lib/postgresql/data postgres:14-alpine
### Copy dump to docker postgres dir
sudo cp /path/to/docker/volumes/tacticalrmm_postgres_data_backup/_data/dump.sql /path/to/docker/volumes/tacticalrmm_postgres_data/_data/dump.sql
### log into updated container/image
sudo docker exec -it temppostgres bash
### Update dump perms
chmod 755 /var/lib/postgresql/data/dump.sql
### import database into updated container/image
psql -U tactical -d tacticalrmm < /var/lib/postgresql/data/dump.sql
### Double-check postgres user settings
psql tacticalrmm tactical
ALTER ROLE tactical SET client_encoding TO 'utf8';
ALTER ROLE tactical SET default_transaction_isolation TO 'read committed';
ALTER ROLE tactical SET timezone TO 'UTC';
GRANT ALL PRIVILEGES ON DATABASE tacticalrmm TO tactical;
quit
exit
### Stop and remove temp postgres container
sudo docker stop temppostgres
sudo docker rm temppostgres
### Change docker compose
change
image: postgres:13-alpine
to
image: postgres:14-alpine
### Start the stack