Backup has failed. pg_dump: server version: 9.6.3; pg_dump version: 9.5.10

AI 生成的摘要

The discussion revolves around a backup failure in Discourse due to a PostgreSQL version mismatch. michaeltcoelho is using PostgreSQL 9.6.3, but Discourse only supports up to version 9.5.x. Falco suggests downgrading to 9.5.x. michaeltcoelho agrees to try it out.

However, pfaffman points out that installing PostgreSQL 9.5 on Ubuntu 17.10 is challenging. Falco provides a solution by using the official PostgreSQL apt repository and installing the 9.5 version. pfaffman appreciates the help and notes that they were previously unable to install the correct version due to binary naming issues.

Falco explains that the issue might be due to Ubuntu 17.10 being skipped in the supported versions. pfaffman is grateful for the clarification and plans to add the solution to a script for installing the development environment.

Hi folks!

I’m getting notified by discourse’s system user about that my backup has failed. On the doc it says that Discourse accepts Postgres 9.3+ versions and i’m using 9.6.3.

[2017-12-02 03:32:09] [STARTED]
[2017-12-02 03:32:09] 'system' has started the backup!
[2017-12-02 03:32:09] Marking backup as running...
[2017-12-02 03:32:09] Making sure '/var/www/discourse/tmp/backups/default/2017-12-02-033209' exists...
[2017-12-02 03:32:09] Making sure '/var/www/discourse/public/backups/default' exists...
[2017-12-02 03:32:09] Pausing sidekiq...
[2017-12-02 03:32:09] Waiting for sidekiq to finish running jobs...
[2017-12-02 03:32:09] Dumping the public schema of the database...
[2017-12-02 03:32:09] perl: warning: Setting locale failed.
[2017-12-02 03:32:09] perl: warning: Please check that your locale settings:
[2017-12-02 03:32:09] LANGUAGE = (unset),
[2017-12-02 03:32:09] LC_ALL = (unset),
[2017-12-02 03:32:09] LANG = "pt_BR.UTF-8"
[2017-12-02 03:32:09] are supported and installed on your system.
[2017-12-02 03:32:09] perl: warning: Falling back to the standard locale ("C").
[2017-12-02 03:32:09] pg_dump: server version: 9.6.3; pg_dump version: 9.5.10
[2017-12-02 03:32:09] pg_dump: aborting because of server version mismatch
[2017-12-02 03:32:09] EXCEPTION: pg_dump failed
[2017-12-02 03:32:09] /var/www/discourse/lib/backup_restore/backuper.rb:170:in `dump_public_schema'
/var/www/discourse/lib/backup_restore/backuper.rb:35:in `run'
/var/www/discourse/lib/backup_restore/backup_restore.rb:163:in `block in start!'
/var/www/discourse/lib/backup_restore/backup_restore.rb:160:in `fork'
/var/www/discourse/lib/backup_restore/backup_restore.rb:160:in `start!'
/var/www/discourse/lib/backup_restore/backup_restore.rb:15:in `backup!'
/var/www/discourse/app/jobs/regular/create_backup.rb:8:in `execute'
/var/www/discourse/app/jobs/base.rb:134:in `block (2 levels) in perform'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rails_multisite-1.1.2/lib/rails_multisite/connection_management.rb:77:in `with_connection'
/var/www/discourse/app/jobs/base.rb:129:in `block in perform'
/var/www/discourse/app/jobs/base.rb:125:in `each'
/var/www/discourse/app/jobs/base.rb:125:in `perform'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:188:in `execute_job'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:170:in `block (2 levels) in process'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq/middleware/chain.rb:128:in `block in invoke'
/var/www/discourse/lib/sidekiq/pausable.rb:80:in `call'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq/middleware/chain.rb:133:in `invoke'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:169:in `block in process'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:141:in `block (6 levels) in dispatch'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq/job_retry.rb:97:in `local'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:140:in `block (5 levels) in dispatch'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq.rb:36:in `block in <module:Sidekiq>'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:136:in `block (4 levels) in dispatch'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:204:in `stats'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:131:in `block (3 levels) in dispatch'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq/job_logger.rb:7:in `call'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:130:in `block (2 levels) in dispatch'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq/job_retry.rb:72:in `global'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:129:in `block in dispatch'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq/logging.rb:44:in `with_context'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq/logging.rb:38:in `with_job_hash_context'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:128:in `dispatch'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:168:in `process'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:85:in `process_one'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:73:in `run'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq/util.rb:16:in `watchdog'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/sidekiq-5.0.5/lib/sidekiq/util.rb:25:in `block in safe_thread'
[2017-12-02 03:32:09] Notifying 'system' of the end of the backup...

Will i have to downgrade my Postgres` versions?

Thanks in advance,
Michael Coelho.

Yes, we currently support PostgreSQL 9.5.x.

Thanks @Falco, i’ll try it out!

If you find a way to install 9.5 on Ubuntu 17.10, I’d love to hear about it. I think that it should be possible with Docker, but I’ve not yet managed.

My solution thus far has been using the docker development environment in discourse/bin/docker, which has a few quirks, but it works.

I actually got DIscourse to work just fine with 9.6, but then I couldn’t restore the import I’d done to a production container.

The official PostgreSQL apt repo currently has: PostgreSQL 9.2, 9.3, 9.4, 9.5, 9.6, 10, 11devel.

Just follow the official instructions: PostgreSQL: Linux downloads (Ubuntu)

TL;DR:

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ zesty-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
sudo apt-get install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt update
sudo apt install postgresql-9.5

Thanks, @falco! I figured there should be a way. I tried what I thought was that, but all of the binaries were named with the version names in them or something, and I couldn’t make that work. I’ve had on my list to come back to figuring this out for a couple weeks now (I generally work at my desktop that’s still on 16.04 and don’t use the laptop much when I’m not travelling).

TL;DR: You saved the day!

Maybe you got bit by the fact that they support: 14.04, 16.04, 17.04 and 18.04 but skipped 17.10.

In the above snipped I set do you get 17.04 packages, that in my experience work just fine.

I bet that was it! And I somehow didn’t think to use the 17.04 repo. I’ll feel a little less silly, so that’s a big help too. :slight_smile:

@techAPJ, if I get ambitious, I’ll see if I can find an elegant way to add this to https://raw.githubusercontent.com/techAPJ/install-rails/master/linux. My goal is to have my new_discourse_database script to not only wipe attachments and make a new database with my admin account, but also install the development environment and create databases owned by the current user if it’s not already installed. I think that if I fix the PSQL version problem it’s done.