Altinity / clickhouse-backup

Tool for easy backup and restore for ClickHouse® using object storage for backup files.
https://altinity.com
Other
1.25k stars 225 forks source link

add support to restore table ON CLUSTER #145

Closed barazbay closed 2 years ago

barazbay commented 3 years ago

If we create table, for example CREATE TABLE recipes ON CLUSTER '{cluster}' ( title String, ingredients Array(String), directions Array(String), link String, source LowCardinality(String), NER Array(String) ) ENGINE = ReplicatedMergeTree('/clickhouse/{cluster}/tables/{shard}/test.recipes', '{replica}') ORDER BY title;

backup metadata will be ATTACH TABLE recipes ( title String, ingredients Array(String), directions Array(String), link String, source LowCardinality(String), NER Array(String) ) ENGINE = ReplicatedMergeTree('/clickhouse/{cluster}/tables/{shard}/test.recipes', '{replica}') ORDER BY title SETTINGS index_granularity = 8192

nothing new, SHOW CREATE TABLE is show create table recipes\G

SHOW CREATE TABLE recipes

Row 1: ────── statement: CREATE TABLE test.recipes ( title String, ingredients Array(String), directions Array(String), link String, source LowCardinality(String), NER Array(String) ) ENGINE = ReplicatedMergeTree('/clickhouse/{cluster}/tables/{shard}/test.recipes', '{replica}') ORDER BY title SETTINGS index_granularity = 8192

1 rows in set. Elapsed: 0.002 sec.

but if I want to restore ON CLUSTER as it was before, it can be easily done if I change restore meta ATTACH TABLE recipes ON CLUSTER '{cluster}' ( title String, ingredients Array(String), directions Array(String), link String, source LowCardinality(String), NER Array(String) ) ENGINE = ReplicatedMergeTree('/clickhouse/{cluster}/tables/{shard}/test.recipes', '{replica}') ORDER BY title SETTINGS index_granularity = 8192 ` it would be nice to add option to restore with 'ON CLUSTER

Slach commented 2 years ago

for current version as workarodund try to use Replicated database engine https://clickhouse.com/docs/en/engines/database-engines/replicated/

Slach commented 2 years ago

@barazbay do you understand properly restore not replicated MergeTree table data ON CLUSTER is not possible? Only Schema