Originally posted by **tadus21** March 8, 2024
Hey,
We have a use case where we store data in ReplicatedMergeTree table which keeps it in different disks according to the TTL.
We noticed that in scenario where:
`DISK_A stores table metadata and data, DISK_B stores just data and by accident DISK_A is lost`
we can just manually move sql file with the attach table statement to `DISK_A/clickhouse/metadata` directory (if we have it backed up). After db restart, the table will be attached to the ClickHouse with all the parts from `DISK_B` present without manually moving them to detach folder and reattaching. This saves time making replica healthy because then ZK only have to restore data from `DISK_A` from the another replica.
I noticed that in backup metadata folder, table creation query have UUID in it so in theory backup tool could recreate the same scenario by running `ATTACH TABLE` instead of `CREATE TABLE`? Would it make sense to provide additional flag to `restore` command which would define whether `ATTACH` or `CREATE` statement should be ran for schema restoration? I seen that something similar is happening when `restore_as_attach` is set to true, but its only relevant when on data restoration flow.
If this make sense I would gladly contribute on this feature.
Discussed in https://github.com/Altinity/clickhouse-backup/discussions/867