mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-01 22:01:49 +00:00
Tweaking postgres upgrade script (#2389)
* Tweaking postgres upgrade script * Removing pointless comments.
This commit is contained in:
parent
8a4d9cc1ba
commit
2f9d8776ac
1 changed files with 11 additions and 20 deletions
|
@ -1,54 +1,45 @@
|
||||||
##!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
## This script upgrades the postgres from version 12 to 14
|
echo "Do not stop in the middle of this upgrade, wait until you see the message: Upgrade complete."
|
||||||
|
|
||||||
## Make sure everything is started
|
echo "Make sure postgres is started..."
|
||||||
sudo docker-compose start
|
sudo docker-compose up -d postgres
|
||||||
|
sleep 20s
|
||||||
|
|
||||||
# Export the DB
|
|
||||||
echo "Exporting the Database to 12_14.dump.sql ..."
|
echo "Exporting the Database to 12_14.dump.sql ..."
|
||||||
sudo docker-compose exec -T postgres pg_dumpall -c -U lemmy > 12_14_dump.sql
|
sudo docker-compose exec -T postgres pg_dumpall -c -U lemmy > 12_14_dump.sql
|
||||||
echo "Done."
|
echo "Done."
|
||||||
|
|
||||||
# Stop everything
|
echo "Stopping postgres..."
|
||||||
sudo docker-compose stop
|
sudo docker-compose stop postgres
|
||||||
|
sleep 20s
|
||||||
|
|
||||||
sleep 10s
|
|
||||||
|
|
||||||
# Delete the folder
|
|
||||||
echo "Removing the old postgres folder"
|
echo "Removing the old postgres folder"
|
||||||
sudo rm -rf volumes/postgres
|
sudo rm -rf volumes/postgres
|
||||||
|
|
||||||
# Change the version in your docker-compose.yml
|
|
||||||
echo "Updating docker-compose to use postgres version 14."
|
echo "Updating docker-compose to use postgres version 14."
|
||||||
sed -i "s/postgres:12-alpine/postgres:14-alpine/" ./docker-compose.yml
|
sed -i "s/postgres:12-alpine/postgres:14-alpine/" ./docker-compose.yml
|
||||||
|
|
||||||
# Start up postgres
|
|
||||||
echo "Starting up new postgres..."
|
echo "Starting up new postgres..."
|
||||||
sudo docker-compose up -d postgres
|
sudo docker-compose up -d postgres
|
||||||
|
|
||||||
# Sleep for a bit so it can start up, build the new folders
|
|
||||||
sleep 20s
|
sleep 20s
|
||||||
|
|
||||||
# Import the DB
|
|
||||||
echo "Importing the database...."
|
echo "Importing the database...."
|
||||||
cat 12_14_dump.sql | sudo docker-compose exec -T postgres psql -U lemmy
|
cat 12_14_dump.sql | sudo docker-compose exec -T postgres psql -U lemmy
|
||||||
echo "Done."
|
echo "Done."
|
||||||
|
|
||||||
POSTGRES_PASSWORD=$(grep "POSTGRES_PASSWORD" ./docker-compose.yml | cut -d"=" -f2)
|
POSTGRES_PASSWORD=$(grep "POSTGRES_PASSWORD" ./docker-compose.yml | cut -d"=" -f2)
|
||||||
|
|
||||||
# Fix weird password issue with postgres 14
|
|
||||||
echo "Fixing a weird password issue with postgres 14"
|
echo "Fixing a weird password issue with postgres 14"
|
||||||
sudo docker-compose exec -T postgres psql -U lemmy -c "alter user lemmy with password '$POSTGRES_PASSWORD'"
|
sudo docker-compose exec -T postgres psql -U lemmy -c "alter user lemmy with password '$POSTGRES_PASSWORD'"
|
||||||
sudo docker-compose restart postgres
|
sudo docker-compose restart postgres
|
||||||
|
|
||||||
# Just in case
|
echo "Setting correct perms for pictrs folder"
|
||||||
sudo chown -R 991:991 volumes/pictrs
|
sudo chown -R 991:991 volumes/pictrs
|
||||||
|
|
||||||
# Start up the rest of lemmy
|
echo "Starting up lemmy..."
|
||||||
echo "Starting up lemmy"
|
|
||||||
sudo docker-compose up -d
|
sudo docker-compose up -d
|
||||||
|
|
||||||
# Delete the DB Dump? Probably safe to keep it
|
|
||||||
echo "A copy of your old database is at 12_14.dump.sql . You can delete this file if the upgrade went smoothly."
|
echo "A copy of your old database is at 12_14.dump.sql . You can delete this file if the upgrade went smoothly."
|
||||||
|
echo "Upgrade complete."
|
||||||
|
|
Loading…
Reference in a new issue