Errors were encountered while processing: postgresql-contrib-9.5

First of all, take a backup and download it!

Then follow this:

cd /var/discourse
mv shared shared_old

Then edit app.yml, removing postgres version from it. After the editing the first lines should look like this:

## this is the all-in-one, standalone Discourse Docker container template
##
## After making changes to this file, you MUST rebuild
## /var/discourse/launcher rebuild app
##
## BE *VERY* CAREFUL WHEN EDITING!
## YAML FILES ARE SUPER SUPER SENSITIVE TO MISTAKES IN WHITESPACE OR ALIGNMENT!
## visit http://www.yamllint.com/ to validate this file as needed
templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
## Uncomment these two lines if you wish to add Lets Encrypt (https)
...

Then ./launcher rebuild app, create an admin, upload a backup and restore. Just make sure to have plenty of space.

This procedure isn’t the fastest, but will work to restore a broken Discourse from any point to a usable and working install.