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: More Backup Restore Fixes #2859

Conversation

michael-genson
Copy link
Collaborator

What type of PR is this?

(REQUIRED)

  • bug

What this PR does / why we need it:

(REQUIRED)

This fixes more backup-restore-related issues by replacing some of the Alembic ORM stuff with raw SQL.

Which issue(s) this PR fixes:

(REQUIRED)

Fixes #2857

Special notes for your reviewer:

(fill-in or delete this section)

This (and other similar issues) seems to only be an issue when folks are restoring from an older versions (i.e. they make a backup, upgrade, then restore). When restoring on the same version as the backup it seems to be fine.

Testing

(fill-in or delete this section)

Ran my ever-growing test suite of backups and they all restored successfully.

@michael-genson michael-genson marked this pull request as draft December 18, 2023 00:03
@michael-genson
Copy link
Collaborator Author

Looking into this a little bit more it seems there's still an issue to look into. Will try to find time tomorrow

@yottabit42
Copy link

Looking into this a little bit more it seems there's still an issue to look into. Will try to find time tomorrow

How can I pull your branch if I'm deploying using Docker? I guess I just need manually update the files in the image? I was planning to try the restore with your branch, then export again, and attempt to import into RC2.

@michael-genson
Copy link
Collaborator Author

That would work, however I'd advise against it since the fix doesn't seem to be fully working. I'd recommend restoring to the version you created your backup from in the meantime.

@yottabit42
Copy link

I still have that instance. I guess I'll just stay on that old beta until you tell me the fixes are released, and then I'll try to switch to the new instance again.

Thank you!

data[key] = AlchemyExporter.DateTimeParser(time=value).time
if self.is_uuid(value):
# convert the data to the current database's native GUID type
data[key] = GUID.convert_value_to_guid(value, self.engine.dialect)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the line that fixes this nightmare

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???? How did you figure this out?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pain

Copy link
Collaborator Author

@michael-genson michael-genson Dec 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual answer though: I stared at a lot of compiled queries and eventually noticed that all of my GUIDs were lowercase and had no dashes. Then I peeked into my backup data and noticed all of my GUIDs had dashes. Then I threw a hail-mary and bypassed our GUID implementation (see: 5cf5abe) and my restores started working

Looking closer at the GUID implementation, we keep the dashes in postgres (i.e. we keep the literal GUID representation as a string) and we convert the GUIDs to 32 char hex in sqlite. So sqlite GUIDs, in our implementation, are assumed to have no dashes. But our backup restore doesn't strip them out if they originally came from postgres

@michael-genson michael-genson marked this pull request as ready for review December 27, 2023 21:34
@michael-genson michael-genson enabled auto-merge (squash) January 3, 2024 04:13
@michael-genson michael-genson merged commit 7602c67 into mealie-recipes:mealie-next Jan 3, 2024
6 checks passed
@yottabit42
Copy link

I'm very excited for this to be released! How will I know which release version this patch makes it into?

@boc-the-git
Copy link
Collaborator

It would've already been deployed under the nightly tag.

@yottabit42
Copy link

Thanks! That's helpful, but since I'm using a packaged version from TrueCharts I won't get the nightly builds. I assume this patch will it make it into RC3 or any later releases? Thanks again!

@boc-the-git
Copy link
Collaborator

Correct, it'll be in whatever the next formal release is. That should be either rc3 or simply v1.0

@yottabit42
Copy link

I am now on 1.1.0, but I cannot upload my backup file. When I select the file, nothing ever happens in the UI to show progress of the file uploading, and even after waiting several minutes it does not appear.

@michael-genson
Copy link
Collaborator Author

That might be a restriction on your webserver, the default often limits the file size

@yottabit42
Copy link

I didn't have the problem with the earlier versions of Mealie with the same database backup. It's 110 MB.

I'm also using the TrueCharts app on TrueNAS so I don't really have much control if what's going on in the container. I might be able to configure it to use an external data store, and then I could try manually copying the database backup into the right location. I'll give that a try tomorrow if I get a chance.

@michael-genson
Copy link
Collaborator Author

Yup that was going to be my next suggestion. If you're able to access the mounted filesystem you can add it directly to the backups folder

@yottabit42
Copy link

Switching to external data storage and moving my backup in myself was successful. The restore worked and I'm back in business!

@michael-genson
Copy link
Collaborator Author

Yay! Glad to hear!

@michael-genson michael-genson deleted the fix/more-backup-issues branch February 4, 2024 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] - "Something Went Wrong!" trying to login after database restore
4 participants