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

Cannot properly back up Plausible Analytics because the schema_migrations table of type TinyLog is ignored #238

Closed
vitobotta opened this issue Aug 3, 2021 · 8 comments

Comments

@vitobotta
Copy link

Hi! Thanks for this project, very useful. I am trying to set up backups for Plausible Analytics, but there is a problem: the table schema_migrations is of type TinyLog and it seems that clickhouse backup ignores it and creates an empty backup for it. I can see with the debug log level that it says "skipped" for that table.

Therefore when I restore from a backup, that table will be empty and the Plausible Analytics app will re-run all the migrations, which fail because the tables etc already exist, so the app doesn't start. How can I ensure that that kind of table is also fully backed up? Thanks!

@Slach
Copy link
Collaborator

Slach commented Aug 4, 2021

according to https://github.com/golang-migrate/migrate/tree/master/database/clickhouse
you can re-define x-migrations-table-engine as MergeTree
and all migration history will backup successfully

@vitobotta
Copy link
Author

Hi @Slach ! And thanks for your reply. Are there any consequences from the app's point of view when using a table whose engine has been changed? Thanks

@Slach
Copy link
Collaborator

Slach commented Aug 4, 2021

@vitobotta I see only one concern here
before applying x-migrations-table-engine, you should create a new table with CREATE schema_migrations_mt AS default.schema_migrations Engine=MergeTree() ORDER BY tuple() move data from the old schema_migrations table and execute DROP TABLE IF EXISTS schema_migrations; RENAME TABLE schema_migrations_mt TO schema_migrations

@vitobotta
Copy link
Author

I see, I will give it a try and see if I manage :D

@AlexAkulov
Copy link
Collaborator

I think the best solution of this issue is to ask the 'Plausible Analytics' developers to use the MergeTree engine instead of TinyLog.

@schnerring
Copy link

schnerring commented Mar 19, 2023

I'm in the same boat... I have been using clickhouse-backup to backup my Plausible Analytics database.

I think the best solution of this issue is to ask the 'Plausible Analytics' developers to use the MergeTree engine instead of TinyLog.

Plausible's migrations table uses the TinyLog engine. Even though I have a very limited understanding of the Plausible Analytics source code and ClickHouse, I'm kind of confident that not the Plausible devs decided what engine to use for the migrations table, but rather the developers of a 3rd party ORM. If that's the case, Plausible isn't the only application suffering from this issue. Maybe @ukutaht or @metmarkosaric can shed some light?

Is there a valid technical reason why TinyLog engine tables aren't supported by clickhouse-backup? If not, I don't think the solution is to design an application around its backup tool.

edit: I didn't mean to necro-post - I can open a new issue if desired.

@Slach
Copy link
Collaborator

Slach commented Mar 19, 2023

@schnerring

Is there a valid technical reason why TinyLog engine tables aren't supported by clickhouse-backup? If not, I don't think the solution is to design an application around its backup tool.

clickhouse-backup works outside from clickhouse-server and use ALTER TABLE ... FREZZE command for safe make hardlinks of current data files, this command doesn't support TinyLog and all other *Log engines

try to use in your configuration:

general:
  use_embedded_backup_restore: true

it will use available in clickhouse-server version 23.x+ BACKUP/RESTORE command,
https://clickhouse.com/docs/en/operations/backup#command-summary

but it also have some bugs
https://github.com/ClickHouse/ClickHouse/issues?q=is%3Aopen+is%3Aissue+author%3ASlach+backup

@schnerring
Copy link

Amazing work, thanks for the info!

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

No branches or pull requests

4 participants