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

[Question] How to convert database to replica propertly? #449

Closed arikodelabs closed 2 years ago

arikodelabs commented 2 years ago

Hello, I have made a script that finds the string in each database and in each json file and replaces them accordingly with:

sed -i "s#ENGINE = MergeTree#ENGINE = ReplicatedMergeTree('/replikimi/$database/shard1/$table', '$2')#g" /var/lib/clickhouse/backup/$1/metadata/$database/$table.json

sed -i "s#ENGINE = AggregatingMergeTree()#ENGINE = ReplicatedAggregatingMergeTree('/replikimi/$database/shard1/$table', '$2')#g" /var/lib/clickhouse/backup/$1/metadata/$database/$table.json The script successfully does it . however when I run clickhouse-backup restore <backupname> It gives me some warnings and when I look into the tables of databases, they have no data and the ones that had MergeTree are not there at all?

Thanks!

Slach commented 2 years ago

is your destination server already contains data or not?

could you try and share the results of LOG_LEVEL=debug clickhouse-backup restore --rm <backup_name> ?

arikodelabs commented 2 years ago

Hello. thanks for your reply! Hope you are well , here is the output: output.log

Hope you have a great day!

Best Regards!

Slach commented 2 years ago

you replacing was wrong

after replace you got wrong engine definition

ENGINE = ReplicatedMergeTree('/replikimi/bms_dev_client_admin/shard1/builtspace_inspections', 'ck-1')()

try replace MergeTree() instead of MergeTree

sed -i "s#ENGINE = MergeTree\(\)#ENGINE = ReplicatedMergeTree('/replikimi/$database/shard1/$table', '$2')#g" /var/lib/clickhouse/backup/$1/metadata/$database/$table.json