Upgrading a very old instance


(Jay Pfaffman) #1

I’m trying to upgrade a very old instance with an old version of postgres.

It says

Add the line: base_image: "samsaffron/discourse:0.1.1"
In containers/app.yml: Change "templates/postgres.template.yml" TO "templates/postgres.9.2.template.yml"

Run ./launcher rebuild app again

When your instance is running:
Run ./launcher enter app
Run cd /shared/postgres_backup && sudo -u postgres pg_dump discourse > backup.db

Undo the base_image in your container config
Run: ./launcher stop app
Run: sudo mv /var/discourse/shared/standalone/postgres_data /var/discourse/shared/standalone/postgres_data_old
Run: ./launcher rebuild app

Run: ./launcher enter app
Run: cd /shared/postgres_backup
Run: sv stop unicorn
Run: sudo -iu postgres dropdb discourse
Run: sudo -iu postgres createdb discourse
Run: sudo -iu postgres psql discourse < backup.db
Run: exit
Run: ./launcher rebuild app

So I add

 base_image: "samsaffron/discourse:0.1.1"

at the beginning of app.yml and replace the postgres line.

Then I get

root@discuss:/var/docker# ./launcher rebuild app
Ensuring launcher is up to date
Fetching origin
Launcher is up-to-date
Stopping old container
+ /usr/bin/docker stop -t 10 app
app
lUnable to find image 'samsaffron/discourse:0.1.1' locally
/usr/bin/docker: Error response from daemon: manifest for samsaffron/discourse:0.1.1 not found.
See '/usr/bin/docker run --help'.
Unable to find image 'samsaffron/discourse:0.1.1' locally
/usr/bin/docker: Error response from daemon: manifest for samsaffron/discourse:0.1.1 not found.
See '/usr/bin/docker run --help'.
cd /pups && git pull && /pups/bin/pups --stdin
Unable to find image 'samsaffron/discourse:0.1.1' locally
/usr/bin/docker: Error response from daemon: manifest for samsaffron/discourse:0.1.1 not found.
See '/usr/bin/docker run --help'.
cat: cids/app_bootstrap.cid: No such file or directory
"docker rm" requires at least 1 argument.
See 'docker rm --help'.

Usage:  docker rm [OPTIONS] CONTAINER [CONTAINER...] [flags]

Remove one or more containers
rm: cannot remove 'cids/app_bootstrap.cid': No such file or directory
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one
root@discuss:/var/docker# l

@sam should this still work?


(Sam Saffron) #2

oh my, not sure … I did not remove it, but maybe docker yanked it. If you are using the old pg template you should be able to nuke the explicit dependency on the base image.


(Jay Pfaffman) #3

Well, I tried samsaffron/discourse:0.1.2, which got further, but then there was no Postgres 9.2. And then I checked https://hub.docker.com/_/postgres/ and there I see no Postgres 9.2., only a 9.3.

I’m not seeing an easy way out of this problem.


(Richard - DiscourseHosting.com) #4

Install 9.3 and try to upgrade it manually?

Like this (or something like this)

sudo -u postgres  /usr/lib/postgresql/9.3/bin/pg_upgrade -b /usr/lib/postgresql/9.2/bin/ -B /usr/lib/postgresql/9.3/bin/ -d /var/lib/postgresql/9.2/main -D /var/
lib/postgresql/9.3/main -o ' -c config_file=/etc/postgresql/9.2/main/postgresql.conf' -O ' -c config_file=/etc/postgresql/9.3/main/postgresql.conf

(Jay Pfaffman) #5

Thanks, @RGJ! It seems like that’s what needs to happen, but 9.2 won’t read the 9.2 database, will it?

But once I got something to read the database I can do a psqldump (or whatever it’s called) to dump it to a file that I can then import into a later version. Would I need to go through each version or could I go straight to 9.5?


(Richard - DiscourseHosting.com) #6

You don’t need pg_dump and in my experience you will get in trouble if you use that to upgrade.

Using pg_upgrade you can upgrade from (almost) any version to current, although I would recommend baby steps here and first do a manual upgrade to the oldest version that is supported by Discourse docker (9.1 to 9.3) and from there on take the supported path (i.e. just switch the template)

pg_upgrade supports upgrades from 8.4.X and later to the current major release of PostgreSQL, including snapshot and alpha releases.


(Jay Pfaffman) #7

Cool. Apparently I’ve been doing a bad job of RTFM/Googling. Thanks again.