Backup fails on localhost with docker

AI-generated summary

Backup fails on localhost with docker

The discussion revolves around an issue with creating a backup from the admin section of a Discourse instance running on localhost with Docker. max-elia initially reports the issue, citing a “Peer authentication failed” error when trying to connect to the database.

After some troubleshooting, natasha_selvidge finds a solution by adding username: discourse directly to the database.yml file under adapter: postgresql. This fix allows for successful backups and restores. natasha_selvidge provides further clarification on the fix, including the location of the modification and the necessary steps to complete the restore process.

I’m having issues with creating a backup from the admin section, running discourse from the docker container on localhost.

The error I’m getting is:
pg_dump: error: connection to database "discourse development" failed: FATAL: Peer authentication failed for user "postgres".

I checked the pg_hba.conf file, and have all options set to trust.

Would be great if I could get some assistance on how to get this to work.

I tried on Ubuntu as well as on MacOSX. Everything else from the discourse instance is working fine on both (creating Posts, API…) except for the backup functionality.

That could be a regression. It should be using user discourse, I’d think.

Where could I change the user being used by discourse?

How did you install?

Following this tutorial:

As I said, everything works fine, except for the backup.

Hi Max! Were you able to fix this issue?
I’m currently having the exact same problem, although I first detected it trying to make a restore on my local docker development install.

Hi @max-elia I’ve also run into this problem, were you able to get it fixed by any chance?

I fixed it by adding username: discourse directly into my database.yml. Thank you!

where in the file did you add it and what else did you do?? Adding it to the development section and simply restarting (d/shutdown_dev; d/boot_dev) didn’t do it for me.

Right under adapter: postgresql in the config/database.yml Then I followed the script/discourse restore <filename.of.the.backup.tar.gz> Which was what I was trying to accomplish.