# Pg\_dump backup failure for remote pgsql - port & version differentials; what options exist?

**URL:** https://meta.discourse.org/t/pg-dump-backup-failure-for-remote-pgsql-port-version-differentials-what-options-exist/132453
**Category:** Self-hosting
**Created:** [November 2, 2019, 6:00pm UTC](https://meta.discourse.org/t/pg-dump-backup-failure-for-remote-pgsql-port-version-differentials-what-options-exist/132453 "2019-11-02T18:00:34Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![mreach](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@mreach](https://meta.discourse.org/u/mreach)
#### Post date: [November 2, 2019, 6:00pm UTC](https://meta.discourse.org/t/pg-dump-backup-failure-for-remote-pgsql-port-version-differentials-what-options-exist/132453/1 "2019-11-02T18:00:34Z")

</div>

When I attempt to run system backups I get: “The backup failed. Please check the logs.”  
The log reports: `pg_dump: [archiver (db)] connection to database "discoursedb" failed: could not connect to server: Connection refused`

I believe there may be two problems at play:

1. The remote server is running on a non-standard port.
2. The remote PostgreSQL is running a newer PSQL version.

When I enter the app (`/var/discourse/launcher enter app`) and execute a manual backup, I noted that initially without the port definition, I got the exact same error:

```plaintext
$ pg_dump -h 123.456.789.101 -U username -W -F t discourse_db > discourse_db_backup.tar
Password:
pg_dump: [archiver (db)] connection to database "discourse_db" failed: could not connect to server: Connection refused
	Is the server running on host "123.456.789.101" and accepting
	TCP/IP connections on port 5432?

```

So that was easily resolved (_ **EXCEPT I don’t know how to force Discourse to use the proper port in backups** _), however the next issue was a little more concerning which is we’re using a newer version of PSQL on the database server:

```plaintext
$ pg_dump -h 123.456.789.101 -p 45678 -U username -W -F t discourse_db > discourse_db_backup.tar
Password:
pg_dump: server version: 11.5 (Ubuntu 11.5-3.pgdg18.04+1); pg_dump version: 10.10 (Debian 10.10-1.pgdg100+1)
pg_dump: aborting because of server version mismatch

```

What can be done in such a situation? Is there a way to get actual system backup functional in such a case or does Discourse + the PostgreSQL database have to be backed up separately?

If the latter is the only option, what’s the PROPER way to backup at least the data? And is there a preferred cohesive mechanism available to do both at the same time without having to write a new script to do this?

---

<div class="post-metadata">

### Author: ![mreach](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@mreach](https://meta.discourse.org/u/mreach)
#### Post date: [November 2, 2019, 6:18pm UTC](https://meta.discourse.org/t/pg-dump-backup-failure-for-remote-pgsql-port-version-differentials-what-options-exist/132453/2 "2019-11-02T18:18:13Z")

</div>

I did find some discussion in [another post](https://meta.discourse.org/t/ability-to-only-backup-uploaded-data/76474) regarding someone who has a slightly comparable situation. The big difference in my case is that we store files on the local server vs S3. I could forego backing up PostgreSQL since that is backed up independently, however I do still need to back up:

- local content and
- Discourse settings

I still would like a consolidated backup with the db + content + settings all in one place, but I’m guessing you don’t/won’t support that and thus I’d like to at least get content + settings into a consolidated package.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [November 2, 2019, 11:09pm UTC](https://meta.discourse.org/t/pg-dump-backup-failure-for-remote-pgsql-port-version-differentials-what-options-exist/132453/3 "2019-11-02T23:09:04Z")

</div>

Postgres 11 isn’t supported. You can look elsewhere for how to restore between versions, but it’ll be some work to get discourse to work with pg11.

---

<div class="post-metadata">

### Author: ![mreach](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@mreach](https://meta.discourse.org/u/mreach)
#### Post date: [November 3, 2019, 1:02am UTC](https://meta.discourse.org/t/pg-dump-backup-failure-for-remote-pgsql-port-version-differentials-what-options-exist/132453/4 "2019-11-03T01:02:22Z")

</div>

Interesting and odd. I had read somewhere that 11 was alright, but aside from that I have a system already deployed to 11 and have not seen any errors or problems (aside from backup) thus far… Now you have me worried…

**Oh, here we go, [according to this post](https://meta.discourse.org/t/postgresql-11-support/119543) PostgreSQL 11 “should just work.”**

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [November 3, 2019, 1:12am UTC](https://meta.discourse.org/t/pg-dump-backup-failure-for-remote-pgsql-port-version-differentials-what-options-exist/132453/5 "2019-11-03T01:12:06Z")

</div>

Yes. I’ve got two systems deployed on pg11 too. They are working fine except I’m doing backups directly. I upgraded pg to 11 in the container. They’ll make backups but not restore them.

---

<div class="post-metadata">

### Author: ![hexadecagram](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hexadecagram/32/262658_2.png) [@hexadecagram](https://meta.discourse.org/u/hexadecagram)
#### Post date: [November 11, 2019, 1:08am UTC](https://meta.discourse.org/t/pg-dump-backup-failure-for-remote-pgsql-port-version-differentials-what-options-exist/132453/6 "2019-11-11T01:08:41Z")

</div>

The Discourse backup system should simply warn and not fail if there is a PostgreSQL version mismatch. I just tried to make a backup myself and because I too am using an external PG server, no tarball was created at all.

---

<div class="post-metadata">

### Author: ![kuaza](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kuaza/32/264151_2.png) [@kuaza](https://meta.discourse.org/u/kuaza)
#### Post date: [August 20, 2022, 6:12pm UTC](https://meta.discourse.org/t/pg-dump-backup-failure-for-remote-pgsql-port-version-differentials-what-options-exist/132453/8 "2022-08-20T18:12:52Z")

</div>

Same problem happened to me. I moved the postgresql database to separate server and started getting backup error. I found the solution by deleting and reinstalling postgresql in docker on the main server.

```plaintext
cd /var/discourse
./launcher enter app
apt-get remove postgresql-client-common
apt-get update
sudo apt-get install postgresql

```

Detail: [Discourse yedekleme pg\_dump hatası ve çözümü: pg\_dump: error: server version: 12|13|14|15|\*; pg\_dump version: 12|13|14|15|\* - Veritabanı Yönetim Sistemleri - Soru Cevap](https://sorucevap.com/t/discourse-yedekleme-pg-dump-hatasi-ve-cozumu-pg-dump-error-server-version-12-13-14-pg-dump-version-12-13-14/113)
