DB backup config error

I upgraded Discourse to latest stable version with complete rebuild yesterday. I’ve got this strange error this morning:

[2018-10-27 04:21:44] 'netpositive' has started the backup! 
[2018-10-27 04:21:44] Marking backup as running... 
[2018-10-27 04:21:44] Making sure '/var/www/discourse/tmp/backups/default/2018-10-27-042144' exists... 
[2018-10-27 04:21:44] Making sure '/var/www/discourse/public/backups/default' exists... 
[2018-10-27 04:21:44] Pausing sidekiq... 
[2018-10-27 04:21:44] Waiting for sidekiq to finish running jobs... 
[2018-10-27 04:21:44] Dumping the public schema of the database... 
[2018-10-27 04:21:44] pg_dump: [archiver (db)] connection to database "discourse" failed: could not connect to server: Connection refused 
[2018-10-27 04:21:44] Is the server running on host "172.17.0.1" and accepting 
[2018-10-27 04:21:44] TCP/IP connections on port 5432? 
[2018-10-27 04:21:44] EXCEPTION: pg_dump failed 
[2018-10-27 04:21:44]
 /var/www/discourse/lib/backup_restore/backuper.rb:172:in `dump_public_schema'
 /var/www/discourse/lib/backup_restore/backuper.rb:37:in `run'
 /var/www/discourse/lib/backup_restore/backup_restore.rb:167:in `block in start!'
 /var/www/discourse/lib/backup_restore/backup_restore.rb:164:in `fork'
 /var/www/discourse/lib/backup_restore/backup_restore.rb:164:in `start!'
 /var/www/discourse/lib/backup_restore/backup_restore.rb:18:in `backup!'
 /var/www/discourse/app/controllers/admin/backups_controller.rb:32:in `create'
[2018-10-27 04:21:44] Notifying 'netpositive' of the end of the backup... 
[2018-10-27 04:21:53] Removing old backups...

The postgresql 9.6 server is running outside the container and it’s accessible on port 5433. If I manually run the pg_dump command inside the container then it works flawlessly and I haven’t detected any other DB related issue in Discourse.

Any idea why does it take wrong config settings? :confused:

Thanks a lot!

I have a feeling this may be your problem

https://github.com/discourse/discourse/blob/master/docs/INSTALL.md

Software Requirements

3 Likes

No, Discourse works still fine with 9.6 and it definitely should not get a connection refused because of the Pg version.

Thanks, somehow I’ve overlooked that. Now on postgresql 10 but the problem still persists :roll_eyes:

1 Like

You could try running the same command Discourse uses for dumps. You can get it by executing the following inside the container:

rails c
BackupRestore::Backuper.new(Discourse.system_user.id, {}).send(:pg_dump_command)
1 Like

It doesn’t work because the port 5432 is used instead of 5433 :frowning:

[1] pry(main)> BackupRestore::Backuper.new(Discourse.system_user.id, {}).send(:pg_dump_command)
=> "PGPASSWORD='redacted' pg_dump --schema=public --file='/var/www/discourse/tmp/backups/default/2018-10-29-184350/dump.sql.gz' --no-owner --no-privileges --verbose --compress=4 --host=172.17.0.1 --port=5432 --username=discourse discourse"

Oh, I totally missed the different ports in your first post. :sweat_smile:

It looks like backups use the default PostgreSQL port unless specified otherwise. I think you might be able to override it by configuring DISCOURSE_DB_BACKUP_PORT: 5433 in your container config.

5 Likes

Thank you, that setting did the trick :relaxed:

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.