So, I have been using postgres 9.3 since the new docker image came out… and just replacing templates/postgres.9.3.template.yml with templates/postgres.template.yml doesn’t work.
Given a current backup, what’s a good way to upgrade the postgres template?
There were a couple older sites on Digital Ocean that failed to upgrade to Postgres 9.5 and I stuck with the old template for 9.3. As I recall it had to do with default db encodings being incorrect on the older images.
Lately I’ve had a few stalls while using the web-based upgrade on this one discourse of mine. Manual rebuilds ( ./launcher rebuild app ) worked, but that’s downtime I’d rather avoid.
There was mention of postgres in the logs I saw… I’ll save them if they happen again… and I saw that I was still on old postres 9.3
encodings for database "postgres" do not match: old "SQL_ASCII", new "UTF8"
The smoothest option for upgrading is almost certainly going to be just to run a full backup of the existing site, spin up a new site, and restore into it, then switch over. If you’ve got access to someone who is a PostgreSQL ninja, there are ways of doing encoding rebuilds (with DB dumps and some judicious editing), but it’s not for the faint of heart, and I, for one, am not going to load the foot-gun by trying to write a sufficiently detailed howto…
Running a second container is straightforward, in general: copy containers/app.yml (or whatever you’ve called it) into, say, containers/app2.yml, edit that new file a bit, and run ./launcher bootstrap app2; ./launcher start app2. The tricky bit is getting HTTP into the new container; if you’re doing the default setup, where the HTTP port is being forwarded directly into the container, you’ll need to use a different port for the new container, and a bit of the ol’ quick-rebuild-shuffle when you go to make the new site live. If you’re using nginx/haproxy/apache to proxy multiple websites, it’s a bit easier, because you can just setup the new site on a new name and add it to the proxy config.
1- download my backup
2- remove the current container (yes, our site will be down for a bit)
3- remove any backups so that a new container won’t try to use them
4- start a fresh container in place
5- re-import this backup
I don’t know how to do step 2 (remove the container)
I don’ t know if step 3 is relevant, or is a part of step 2
If you’re OK with some downtime, then this should work:
Take and download backup
./launcher stop app
docker rm app
mv shared/standalone shared/standalone.9.3
Edit containers/app.yml to change the postgres.9.3 to postgres
./launcher bootstrap app; ./launcher start app
Import the backup
Step 4 is the step that “makes the current container cease to exist” in a meaningful sense. shared/app is where all of the PostgreSQL data, logs, etc live. By renaming it, rather than just deleting it, you’re leaving yourself with a fallback plan if the unexepected happens and everything goes to hell.