docker icon indicating copy to clipboard operation
docker copied to clipboard

Database Restore Error

Open monzer94 opened this issue 3 years ago • 14 comments

Hello Everyone I am trying to upgrade to calcom I toke a backup for our database from inside the container using "docker exec -i postgres /usr/bin/pg_dump
-U <postgresql_user> <postgresql_database> > postgres-backup.sql " then I pulled the latest repo and edited the env file and build the image, every thing worked good and services started correctly. The issue is when I try to restore the old backup to the new DB I get this error 1212

I even Tried to drop the db then creating it again and restore then I get this error from the dashboard 1213

Any help would be appreciated

monzer94 avatar Aug 29 '22 16:08 monzer94

@zomars @PeerRich should issues like these be encouraged to be moved to the core repos? @monzer94 if you're able to convert those images back to the embedded images instead of google drive, it would be helpful for archiving.

thanks!

krumware avatar Aug 29 '22 16:08 krumware

@zomars @PeerRich should issues like these be encouraged to be moved to the core repos? @monzer94 if you're able to convert those images back to the embedded images instead of google drive, it would be helpful for archiving.

thanks!

Could you please help with that, sorry but i am new to open issues in github

monzer94 avatar Aug 29 '22 16:08 monzer94

fixed images.

no this is a docker issue, not core, no?

PeerRich avatar Aug 29 '22 17:08 PeerRich

it seems like a migration is missing?

PeerRich avatar Aug 29 '22 17:08 PeerRich

it seems like a migration is missing?

From what I read in the discussion, the migration should start automatically once I run the services. Is there anything from my end I can try?

monzer94 avatar Aug 29 '22 18:08 monzer94

The docker image runs the same migrations as the core project and doesn't do anything differently there, that's why I think it may be an issue in core. It isn't desired, but are you able to try running the core project outside of docker and configure it for your database to see if you have the same issue?

krumware avatar Aug 29 '22 19:08 krumware

no I didn't try that, but what I just found right now, the migration is running and it detect 120 migration but it exits on a command "yarn run dp=deploy exited" and then it enter in loop of this error "P3009" https://drive.google.com/file/d/1ePN8PGS-qecOAH66D1CwiId-DdUCJkEI/view?usp=sharing

monzer94 avatar Aug 29 '22 19:08 monzer94

Just thinking out loud here as I'm no docker expert, but it seems to me the problem is you're trying to restore a backup from a different version of cal, into a new version of cal, you should make it the inverse I think, upgrade your database to latest (version you want to run), then back it up, and then import that into the latest running version on docker.

Otherwise the databases won't match, and thus you cannot import the backup safely into a database with different shape.

Let us know if that worked for you!

Best regards, Agusti

agustif avatar Aug 29 '22 20:08 agustif

I checked the postgres db version on the old and the new cal version and they are both 14.0 https://drive.google.com/file/d/1QqS1p4lXo-EoTtZZOVjvYrfOd6EgREZx/view?usp=sharing 111old

monzer94 avatar Aug 29 '22 20:08 monzer94

I checked the postgres db version on the old and the new cal version and they are both 14.0 drive.google.com/file/d/1QqS1p4lXo-EoTtZZOVjvYrfOd6EgREZx/view?usp=sharing 111old

Yeah, sorry I should probably been clearer, I meant cal app version. not postgresql version. Since at each release we might change the tables and columns of the database, and so if you try to make a backup in one version of cal into a newer one, the tables mismatch and the backup can't proceed

agustif avatar Aug 29 '22 20:08 agustif

Ok, and sorry if this is a beginner question, but how to update my cal version, because the only thing I found related to the docker deployment is pull the latest and upgrade, could you please help me with that.

monzer94 avatar Aug 29 '22 20:08 monzer94

you could try to run yarn prisma db push or yarn prisma db deploy on your current database (after backing it up, in case it breaks something), that should migrate your current data to latest version I think. After upgrading to latest version you want of course

This prisma docs link might be of help https://www.prisma.io/docs/guides/database/patching-production

agustif avatar Aug 29 '22 20:08 agustif

you could try to run yarn prisma db push or yarn prisma db deploy on your current database (after backing it up, in case it breaks something), that should migrate your current data to latest version I think. After upgrading to latest version you want of course

So on the old cal I am running prisma v2 while in the new cal they are running prisma v3, so you suggest to upgrade old cal prisma to the same version then backup and restore right?

monzer94 avatar Aug 30 '22 12:08 monzer94

Hi I try to upgrade the prisma on the old cal then do run yarn prisma db pushm but the db wont update some rows and tables, please any idea to help

monzer94 avatar Sep 01 '22 14:09 monzer94