#QueryFailedError: relation "migrations" already exists
1 messages · Page 1 of 1 (latest)
The immich server initializes the db on its first startup, so you have to first start the db, restore your backup and then start the other containers.
Otherwise, the backup will conflict with the newly initialized objects in the db.
I'm pretty sure I done this that way. But I will do it again 🙂
You can post the commands you used here if you need some help. Most of them are outlined here: https://immich.app/docs/administration/backup-and-restore/
I could not use pg_dumpall because of k8s. So I just dumped only the immich database. But this should work as well, right?
Yes.
Will I break anything, when I only restore the database, but not the images (i will do this later)?
it shouldn't break anything
nice thx
Does not work. Same error again 😦
please send over the exact commands you are running
postgres@red bolt-cnpg-main-1:~/data$ gunzip < immich.sql.gz | sed "s/SELECT pg_catalog.set_config('search_path', '', false);/SELECT pg_catalog.set_config('search_path', 'public, pg_catalog', true);/g" | psql --username=postgres --dbname immich
for backup
docker exec -t immich_postgres pg_dump --clean --if-exists --username=postgres immich | gzip > "immich.sql.gz"
Ok, let's start over, reset everything and before you run the gunzip you should shell into the database using psql immich and run \d+
sure.. just a sec
let me know what that shows
and to be safe can you do \l+
That looks fine. At this point you should be able to start up Immich
If you restart Immich one more time, does it still log that error?
and/or does Immich actually work?
I don't think migrations is not the first table to be created, so I wonder if there's a first run script that is trying to create it for some reason
actually it looks like it's a crash loop isn't it
I think it might be a permissions issue.. let's try doing a re restore but use the command: psql --dbname=immich --username=immich
This might be because you are not using pg_dumpall
ok. lets do it again 😄
Sorry! Tricky situation. The restore commands are based on pg_dumpall which contains more permissions
pg_dump is just rows and tables I think
Yes used pg_dumpall before. It works, but is more tricky because I need to reset the password. But I ended up with the exact same error
But lets do it again 🙂
surprised pg_dumpall had the same error.. hmm. I hope this helps
Could this happend because my old immich version was not up2date but the newone is?
How much not up to date? It could yes
Some kind of policy does not allow access from cli for user immich. (Yes the password is correct)
It’s not obviously stored in the DB. can you check the DB dump for any lines containing the word OWNER?
Also are any errors printed when you do the restore? Can you post the output of the restore command from the first way of doing it as username=postgres
This looks wrong, right? This should be owned by user immich
because docker uses the postgres user, but truecharts uses an extra user?
Docker does not use the Postgres user, it uses an Immich user
Either way, your previous backup is quite odd
I recommend doing the restore, like it worked before, then run all those lines but change it to immich
I've not piped it. It's gone, but has no errors printed
Yes sir...
Actually, a few of those should stay as Postgres.. give me a few minutes to check which ones
ok
Are you using this DB for anything else?
no
Then it should be fine to own all them to immich
uhhh, new error
lets restart postgres...
Great! Really weird issue. Not sure how that happened
Please keep a record of the tables you owned to immich. In case there is an issue down the line you will know what to change back
Maybe it’d be simpler to just set the schema owner there after all
It would be, my goal originally was to allow for multiple instances of Immich in one DB
I think this is the only thing that would conflict if we changed the owner
I'm honestly surprised that ALTER DEFAULT seemed to not work - baffles me (though it wasn't run in this case)
Yeah, I have no clue why that doesn’t work. I’d be interested to see if 0.2.1 behaves any differently here
We could update the default to that if so
Wait, I think I'm dumb. Schemas in postgres are a subset of databases, right?
For example if I do \dn+ in the postgres database I only see the public schema, but in the immich DB I see the vectors schema
So maybe we can just to alter owner...... I actually have two instances of Immich in my database so I will do some testing
I just did ALTER SCHEMA vectors OWNER TO... and ALTER TABLE pg_vector_index_stat OWNER TO... and both Immich instances are running fine
If we alter the schema owner first, the table owner will inherit, yes?
I have nearly no knowledge about pg :/ So I can't help you there