# Error when upgrading discourse from 1.7

**URL:** https://meta.discourse.org/t/error-when-upgrading-discourse-from-1-7/56135
**Category:** Self-hosting
**Created:** [21 januari 2017 om 17:24 UTC](https://meta.discourse.org/t/error-when-upgrading-discourse-from-1-7/56135 "2017-01-21T17:24:38Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![wil93](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wil93/32/121264_2.png) [@wil93](https://meta.discourse.org/u/wil93)
#### Post date: [21 januari 2017 om 17:24 UTC](https://meta.discourse.org/t/error-when-upgrading-discourse-from-1-7/56135/1 "2017-01-21T17:24:38Z")

</div>

Since I encountered encoding issues I skipped upgrading the DB so I used “templates/postgres.9.3.template.yml” instead of “templates/postgres.template.yml”. Now when I try to rebuild I get this:

```
The following packages will be REMOVED:
  postgresql-9.5 postgresql-client-9.5 postgresql-contrib-9.5
0 upgraded, 0 newly installed, 3 to remove and 0 not upgraded.
After this operation, 26.1 MB disk space will be freed.
(Reading database ... 34533 files and directories currently installed.)
Removing postgresql-contrib-9.5 (9.5.5-1.pgdg16.04+1) ...
update-alternatives: warning: forcing reinstallation of alternative /usr/share/postgresql/9.5/man/man1/postmaster.1.gz because link group postmaster.1.gz is broken
update-alternatives: error: error creating symbolic link '/usr/share/man/man1/postmaster.1.gz.dpkg-tmp': No such file or directory
dpkg: error processing package postgresql-contrib-9.5 (--remove):
 subprocess installed pre-removal script returned error exit status 2
dpkg: postgresql-9.5: dependency problems, but removing anyway as you requested:
 postgresql-contrib-9.5 depends on postgresql-9.5 (= 9.5.5-1.pgdg16.04+1).

Removing postgresql-9.5 (9.5.5-1.pgdg16.04+1) ...
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of stop.
Removing postgresql-client-9.5 (9.5.5-1.pgdg16.04+1) ...
Processing triggers for postgresql-common (178.pgdg16.04+1) ...
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
Errors were encountered while processing:
 postgresql-contrib-9.5

FAILED
--------------------
Pups::ExecError: apt-get remove -y postgresql-9.5 postgresql-client-9.5 postgresql-contrib-9.5 failed with return #<Process::Status: pid 17 exit 100>
Location of failure: /pups/lib/pups/exec_command.rb:108:in `spawn'

```

So I tried to change the line back to “templates/postgres.template.yml” and try with that. However I see this error:

```
Performing Consistency Checks
-----------------------------
Checking cluster versions ok

*failure*
Consult the last few lines of "pg_upgrade_server.log" for
the probable cause of the failure.

connection to database failed: could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/var/lib/postgresql/.s.PGSQL.50432"?

could not connect to old postmaster started with the command:
"/usr/lib/postgresql/9.3/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "/shared/postgres_data" -o "-p 50432 -b -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_directories='/var/lib/postgresql'" start
Failure, exiting
-------------------------------------------------------------------------------------
UPGRADE OF POSTGRES FAILED

You are going to need to export your data and import into a clean instance:

In containers/app.yml: Change "templates/postgres.template.yml" TO "templates/postgres.9.3.template.yml"

Run ./launcher rebuild app again
...
...

```

I tried to enter the docker container to see why the command failed. I run the `/usr/lib/postgresql/9.3/bin/pg_ctl ...` command manually, and I saw that the command (which, I think, starts up a new postgres 9.3 server) failed because there was already an instance of postgres 9.3 running. So I tried to stop that instance but, everytime I `rebuild`, postgres is automatically restarted.

So I tried to do `systemctl disable postgresql` (or `update-rc.d postgresql disable`) but it doesn’t work. It just says:

```
insserv: warning: current start runlevel(s) (empty) of script `postgresql' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `postgresql' overrides LSB defaults (0 1 6).

```

but on the next rebuild, postgres is running again.

I can’t get postgres to **not run** at startup… any ideas?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [21 januari 2017 om 20:46 UTC](https://meta.discourse.org/t/error-when-upgrading-discourse-from-1-7/56135/2 "2017-01-21T20:46:26Z")

</div>

Do you have any recommendations here @falco? I know I skipped pg upgrade on a few older sites as well…

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [21 januari 2017 om 21:02 UTC](https://meta.discourse.org/t/error-when-upgrading-discourse-from-1-7/56135/3 "2017-01-21T21:02:13Z")

</div>

The easiest way is to move/rename the shared folder, bootstrap a new site and then restore from last backup. Can you afford this disk space?

---

<div class="post-metadata">

### Author: ![wil93](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wil93/32/121264_2.png) [@wil93](https://meta.discourse.org/u/wil93)
#### Post date: [21 januari 2017 om 23:13 UTC](https://meta.discourse.org/t/error-when-upgrading-discourse-from-1-7/56135/4 "2017-01-21T23:13:01Z")

</div>

Thanks 🙂

> [@Falco](#):
>
> and then restore from last backup

When I upload the backup file, I see it in the backup list, but the “restore” button is greyed out. What should I do?

EDIT: nevermind, I had to enable backup recovery from the admin settings.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [8 juni 2024 om 12:45 UTC](https://meta.discourse.org/t/error-when-upgrading-discourse-from-1-7/56135/5 "2024-06-08T12:45:03Z")

</div>

This topic was automatically closed after 2694 days. New replies are no longer allowed.
