Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(docs): database name for restore commands #15276

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

mmomjian
Copy link
Contributor

When connecting to psql, it by default connects to a database that matches the username. This works for our standard setup (user=postgres), since the postgres database always exists. However, this is not the case for all users.

Fixes #15227

@mmomjian mmomjian added documentation Improvements or additions to documentation changelog:documentation labels Jan 12, 2025
Copy link
Contributor

📖 Documentation deployed to pr-15276.preview.immich.app

@bo0tzz
Copy link
Member

bo0tzz commented Jan 12, 2025

Can we just source .env for all of these?

@mmomjian mmomjian marked this pull request as draft January 12, 2025 11:14
@mmomjian
Copy link
Contributor Author

mmomjian commented Jan 12, 2025

That's a good idea but I tried that, I did some testing on my end, it only works if we wrap it in bash -c which is really ugly. Since we are moving to no .env, we can't interpret it on the host.

I wouldn't feel super confident doing our commands wrapped in bash, especially the restore. Things can get weird.

source, 2

$ docker exec -it immich_postgres psql --username='$POSTGRES_USER' --dbname='$POSTGRES_DB'
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  role "$POSTGRES_USER" does not exist
$ docker exec -it immich_postgres psql --username='\$POSTGRES_USER' --dbname='$POSTGRES_DB'
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  role "\$POSTGRES_USER" does not exist
$ docker exec -it immich_postgres psql --username='\\$POSTGRES_USER' --dbname='$POSTGRES_DB'
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  role "\\$POSTGRES_USER" does not exist
$ docker exec -it immich_postgres psql --username='$${POSTGRES_USER}' --dbname='$POSTGRES_DB'
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  role "$${POSTGRES_USER}" does not exist
$ docker exec -it immich_postgres psql --username="$${POSTGRES_USER}" --dbname='$POSTGRES_DB'
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  role "65294{POSTGRES_USER}" does not exist
$ docker exec -it immich_postgres bash -c 'psql --username="${POSTGRES_USER}" --dbname="$POSTGRES_DB"'
psql (14.10 (Debian 14.10-1.pgdg120+1))
Type "help" for help.

@mmomjian mmomjian marked this pull request as ready for review January 12, 2025 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:documentation documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants