Pg_dumpによるリモートPgsqlのバックアップ失敗:ポートとバージョンの違い、利用可能なオプションは?

システムバックアップを実行しようとすると、「バックアップに失敗しました。ログを確認してください。」というエラーが表示されます。

ログには以下のように報告されています:
pg_dump: [archiver (db)] connection to database "discoursedb" failed: could not connect to server: Connection refused

問題点は以下の 2 点ではないかと考えています:

  1. リモートサーバーが非標準ポートで実行されている。
  2. リモートの PostgreSQL が新しい PSQL バージョンで実行されている。

アプリにログイン(/var/discourse/launcher enter app)して手動でバックアップを実行したところ、ポート定義なしで実行すると、最初と同じエラーが発生することがわかりました:

$ 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?

これは簡単に解決できました(ただし、Discourse に適切なポートを使用してバックアップさせる方法がわかりません)。しかし、次の問題はより深刻でした。データベースサーバー側で新しいバージョンの PSQL を使用していることです:

$ 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

このような状況でどのような対応が可能でしょうか?システムバックアップを正常に動作させる方法はありますか、それとも Discourse と PostgreSQL データベースは個別にバックアップする必要がありますか?

後者が唯一の選択肢である場合、少なくともデータをバックアップする適切な方法は何ですか?また、新しいスクリプトを作成することなく、両方を同時にバックアップするための推奨される統合メカニズムは存在しますか?

I did find some discussion in another post 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.

「いいね!」 1

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.

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 PostgreSQL 11 "should just work."

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.

「いいね!」 4

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.

同じ問題が私にも発生しました。PostgreSQLデータベースを別のサーバーに移動したところ、バックアップエラーが発生するようになりました。メインサーバーのDockerでPostgreSQLを削除して再インストールすることで解決策を見つけました。

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

詳細: 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