I came up with an idea that I’m trying to implement, but have encountered a few obstacles.
I have a 250GB volume attached to the droplet. So I decided to create a folder: /shared/standalone/t
and symlink it to a folder in the volume.
Next, I edited the postgres.template.yml
and changed all references of /shared/postgres_data_new
to /shared/t/postgres_data_new
.
What I expect is that /shared/
of the container gets mounted to /var/discourse/shared/standalone/
, and then when the postgres 9.5>10 upgrade process starts, it will create /var/discourse/shared/standalone/t/postgres_data_new
, which in fact will be created at the 250G volume.
However, when the postgres upgrade process starts, it fails with the following error:
install: cannot create directory ‘/shared/t’: File exists
Why does it try to create a /shared/t
directory, and not /shared/t/postgres_data_new
. What am I missing in the postgres.template.yml
file?
P.S. I also commented out the following section:
# free_disk=$(df /shared | tail -n 1 | awk '{print $4}')
# required=$(($(du -s /shared/postgres_data | awk '{print $1}') * 2))
#if [ "$free_disk" -lt "$required" ]; then
# echo "WARNING: Upgrading PostgresSQL would require an addtional $(numfmt --to=si $(($required - $free_disk))) of disk space"
# echo "Please free up some space, or expand your disk, before continuing."
# echo ''
# echo 'To avoid upgrading change "templates/postgres.template.yml" TO "templates/postgres.9.5.template.yml" in containers/app.yml'
# exit 1
#fi
UPD.
Finally, I succeeded upgrading Postgres from 9.5 to 10 with limited disk space.
So, here is how.
Upgrading PostgreSQL from 9.5 to 10 with limited disk space
So if your disk is e.g. 60GB and system + database takes 35GB, you won’t be able to update Postgres to the newer major version, as it requires free space that is 2x of the database space.
Here is a workaround that worked for me.
Step 1. Buy / mount a volume (this is only needed temporarily). Create a folder in the volume. In my case the folder name is t
.
Step 2. Edit containers/app.yml
and add a new volume:
- volume:
host: /mnt/volume-fra1-01-part1/t
guest: /shared/t
In this example, /mnt/volume-fra1-01-part
is the path to the mounted volume. Change it to reflect yours.
Step 3. Backup your templates/postgres.template.yml
file, then edit it:
Find path: /root/upgrade_postgres
and comment out the following section:
# free_disk=$(df /shared | tail -n 1 | awk '{print $4}')
# required=$(($(du -s /shared/postgres_data | awk '{print $1}') * 2))
#if [ "$free_disk" -lt "$required" ]; then
# echo "WARNING: Upgrading PostgresSQL would require an addtional $(numfmt --to=si $(($required - $free_disk))) of disk space"
# echo "Please free up some space, or expand your disk, before continuing."
# echo ''
# echo 'To avoid upgrading change "templates/postgres.template.yml" TO "templates/postgres.9.5.template.yml" in containers/app.yml'
# exit 1
#fi
Also, change all references of:
/shared/postgres_data_new
to /shared/t/postgres_data_new
/shared/postgres_data_old
to /shared/t/postgres_data_old
(the /t/ is added to the path).
Step 4. Rebuild your Discourse instance:
cd /var/discourse
./launcher rebuild app
Step 5 Edit file app.yml
and remove the volume we added previously. Restore the postgres.template.yml
Step 6. Rebuild your Discourse instance again.