]> Untitled Git - lemmy.git/blob - scripts/postgres_12_to_15_upgrade.sh
Fix wrong SMTP port when TLS is being used (fixes #3574) (#3607)
[lemmy.git] / scripts / postgres_12_to_15_upgrade.sh
1 #!/bin/sh
2 set -e
3
4 echo "Do not stop in the middle of this upgrade, wait until you see the message: Upgrade complete."
5
6 echo "Stopping lemmy and all services..."
7 sudo docker-compose stop
8
9 echo "Make sure postgres is started..."
10 sudo docker-compose up -d postgres
11 sleep 20s
12
13 echo "Exporting the Database to 12_15.dump.sql ..."
14 sudo docker-compose exec -T postgres pg_dumpall -c -U lemmy > 12_15_dump.sql
15 echo "Done."
16
17 echo "Stopping postgres..."
18 sudo docker-compose stop postgres
19 sleep 20s
20
21 echo "Removing the old postgres folder"
22 sudo rm -rf volumes/postgres
23
24 echo "Updating docker-compose to use postgres version 15."
25 sed -i "s/image: postgres:.*/image: postgres:15-alpine/" ./docker-compose.yml
26
27 echo "Starting up new postgres..."
28 sudo docker-compose up -d postgres
29 sleep 20s
30
31 echo "Importing the database...."
32 cat 12_15_dump.sql | sudo docker-compose exec -T postgres psql -U lemmy
33 echo "Done."
34
35 POSTGRES_PASSWORD=$(grep "POSTGRES_PASSWORD" ./docker-compose.yml | cut -d"=" -f2)
36
37 echo "Fixing a weird password issue with postgres 15"
38 sudo docker-compose exec -T postgres psql -U lemmy -c "alter user lemmy with password '$POSTGRES_PASSWORD'"
39 sudo docker-compose restart postgres
40
41 echo "Setting correct perms for pictrs folder"
42 sudo chown -R 991:991 volumes/pictrs
43
44 echo "Starting up lemmy..."
45 sudo docker-compose up -d
46
47 echo "A copy of your old database is at 12_15.dump.sql . You can delete this file if the upgrade went smoothly."
48 echo "Upgrade complete."