{"id":16430151,"url":"https://github.com/its-alex/clickhouse-backup-playground","last_synced_at":"2026-05-16T03:37:15.571Z","repository":{"id":249723710,"uuid":"832335553","full_name":"Its-Alex/clickhouse-backup-playground","owner":"Its-Alex","description":"Playground to backup clickhouse","archived":false,"fork":false,"pushed_at":"2024-08-08T19:20:22.000Z","size":27,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-23T11:12:29.366Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Its-Alex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-22T20:13:20.000Z","updated_at":"2024-08-08T19:20:26.000Z","dependencies_parsed_at":"2024-11-10T17:54:00.036Z","dependency_job_id":null,"html_url":"https://github.com/Its-Alex/clickhouse-backup-playground","commit_stats":null,"previous_names":["its-alex/clickhouse-backup-playground"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Its-Alex%2Fclickhouse-backup-playground","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Its-Alex%2Fclickhouse-backup-playground/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Its-Alex%2Fclickhouse-backup-playground/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Its-Alex%2Fclickhouse-backup-playground/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Its-Alex","download_url":"https://codeload.github.com/Its-Alex/clickhouse-backup-playground/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240672846,"owners_count":19838928,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T08:25:51.282Z","updated_at":"2026-05-16T03:37:15.565Z","avatar_url":"https://github.com/Its-Alex.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- omit in toc --\u003e\n# Clickhouse backup playground\n\nThis repository is used as playground to backup [clickhouse](https://clickhouse.com/) using\n[clickhouse-backup from Altinity](https://github.com/Altinity/clickhouse-backup).\n\n- [Requirements](#requirements)\n- [Getting started](#getting-started)\n- [Perform a manual backup](#perform-a-manual-backup)\n- [Restore a backup](#restore-a-backup)\n- [License](#license)\n\n## Requirements\n\n- [mise](https://mise.jdx.dev/)\n- [docker](https://www.docker.com/)\n- [bash](https://www.gnu.org/software/bash/)\n\n## Getting started\n\nFirst you can launch the stack using:\n\n```bash\n$ ./scripts/up.sh\n[+] Running 2/2\n ✔ Network clickhouse-backup-playground_default    Created\n ✔ Container clickhouse-backup-playground-minio-1  Healthy\nAdded `default` successfully.\nBucket created successfully `default/clickhouse-backup`.\nmc: Please use 'mc anonymous'\nAccess Key: root-service-account\nSecret Key: root-service-account-secret\nExpiration: no-expiry\n[+] Running 1/1\n ✔ Container clickhouse-backup-playground-clickhouse-1  Healthy\n[+] Copying 1/1\n ✔ clickhouse-backup-playground-clickhouse-1 copy fixtures.sql to clickhouse-backup-playground-clickhouse-1:/fixtures.sql Copied\n[+] Running 3/3\n ✔ Container clickhouse-backup-playground-clickhouse-1         Healthy\n ✔ Container clickhouse-backup-playground-minio-1              Running\n ✔ Container clickhouse-backup-playground-clickhouse-backup-1  Started\n```\n\nThis script will:\n\n1. Launch a [minio](https://min.io/) instance\n1. Create a bucket `clickhouse-backup` for backups\n1. Launch a [clickhouse](https://clickhouse.com/) databse instance\n1. Import [fixtures](./fixtures.sql) into the [clickhouse](https://clickhouse.com/)\n   databse instance\n1. Launch a [clickhouse-backup](https://github.com/Altinity/clickhouse-backup)\n   instance configured to watch clickhouse database and do regular backups\n\nYou're now running a clickhouse database with fixtures that is regularly backup\nusing clickhouse-backup.\n\nBy default a backup is performed when clickhouse-backup is launched, you can\nlist backup using:\n\n```bash\n$ docker compose exec clickhouse-backup /bin/clickhouse-backup list remote\n...\nshard{shard}-full-20250420202211        20/04/2025 20:22:11   remote                                       all:82.52KiB,data:74.28KiB,arch:82.00KiB,obj:529B,meta:0B,rbac:0B,conf:0B   tar, regular\nshard{shard}-increment-20250420202711   20/04/2025 20:27:11   remote   +shard{shard}-full-20250420202211   all:485B,data:0B,arch:0B,obj:485B,meta:0B,rbac:0B,conf:0B                   tar, regular\n...\n```\n\nYou can see and edit configuration in [docker-compose.yml](./docker-compose.yml).\n\n## Perform a manual backup\n\nTo manually perform a backup you can use:\n\n```bash\n$ docker compose exec clickhouse-backup /bin/clickhouse-backup create_remote\n...\n2025-04-20 20:29:37.463 INF pkg/backup/upload.go:256 \u003e done backup=2025-04-20T20-29-37 duration=60ms object_disk_size=0B operation=upload upload_size=83.20KiB version=2.6.15\n2025-04-20 20:29:37.465 INF pkg/storage/general.go:163 \u003e list_duration=1.906533\n2025-04-20 20:29:37.465 INF pkg/backup/upload.go:290 \u003e calculate backup list for delete remote duration=2ms operation=RemoveOldBackupsRemote\n2025-04-20 20:29:37.465 INF pkg/backup/upload.go:308 \u003e done duration=2ms operation=RemoveOldBackupsRemote\n2025-04-20 20:29:37.466 INF pkg/clickhouse/clickhouse.go:336 \u003e clickhouse connection closed\n```\n\nThen you can list backup to see the one performed:\n\n```bash\n$ docker compose exec clickhouse-backup /bin/clickhouse-backup list remote\n...\nshard{shard}-full-20250420202211        20/04/2025 20:22:11   remote                                       all:82.52KiB,data:74.28KiB,arch:82.00KiB,obj:529B,meta:0B,rbac:0B,conf:0B   tar, regular\nshard{shard}-increment-20250420202711   20/04/2025 20:27:11   remote   +shard{shard}-full-20250420202211   all:485B,data:0B,arch:0B,obj:485B,meta:0B,rbac:0B,conf:0B                   tar, regular\n2025-04-20T20-29-37                     20/04/2025 20:29:37   remote                                       all:82.52KiB,data:74.28KiB,arch:82.00KiB,obj:529B,meta:0B,rbac:0B,conf:0B   tar, regular\n```\n\n## Restore a backup\n\nFirst you should probably perform a backup using\n[perform a manual backup](#perform-a-manual-backup). When you have a backup\nyou must edit the database, for exemple we can remove the `fixtures.events`\ntable using [](./scripts/execute-query-in-clickhouse.sh):\n\n```bash\n$ ./scripts/execute-query-in-clickhouse.sh \"DROP TABLE fixtures.events SYNC\"\n```\n\nThen check that table has been deleted:\n\n```bash\n$ ./scripts/execute-query-in-clickhouse.sh \"SELECT * FROM fixtures.events\"\nReceived exception from server (version 25.3.2):\nCode: 60. DB::Exception: Received from localhost:9000. DB::Exception: Unknown table expression identifier 'fixtures.events' in scope SELECT * FROM fixtures.events. (UNKNOWN_TABLE)\n(query: SELECT * FROM fixtures.events)\n```\n\nIf table has been deleted, you can now restore the last backup using:\n\n```bash\n$ ./scripts/restore-last-backup.sh\n...\n2025-04-20 20:36:38.129 INF pkg/backup/restore.go:1456 \u003e done database=fixtures duration=1ms operation=restoreDataRegular progress=1/1 table=events\n2025-04-20 20:36:38.130 INF pkg/backup/restore.go:1368 \u003e done backup=shard{shard}-full-20250420203211 duration=27ms operation=restore_data\n2025-04-20 20:36:38.130 INF pkg/backup/restore.go:261 \u003e done duration=42ms operation=restore version=2.6.15\n2025-04-20 20:36:38.130 INF pkg/clickhouse/clickhouse.go:336 \u003e clickhouse connection closed\n```\n\nNow table `fixtures.events` should be restored:\n\n```bash\n$ ./scripts/execute-query-in-clickhouse.sh \"SELECT COUNT(*) FROM fixtures.events\"\n5000\n```\n\n## License\n\n[MIT](/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fits-alex%2Fclickhouse-backup-playground","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fits-alex%2Fclickhouse-backup-playground","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fits-alex%2Fclickhouse-backup-playground/lists"}