โ† Previous: Module 6 - Query Optimization ๐Ÿ  Home Next: Module 8 - Disaster Recovery โ†’

๐Ÿ’พ MODULE 7

Backup, Recovery & Point-in-Time Recovery (PITR)
Duration: 4-5 hours | Week 5
๐Ÿ“– What is Backup, Recovery & PITR?

Core Concepts

Backup & Recovery is the process of creating copies of your ClickHouse data and being able to restore it when needed. Point-in-Time Recovery (PITR) allows you to restore your database to any specific point in time, not just to the most recent backup. Together, these form your disaster recovery strategy.

๐Ÿ’พ

Full Backups

Complete copy of all data at a specific moment. Slower but simple recovery.

๐Ÿ“Š

Incremental Backups

Only new/changed data since last backup. Fast and storage-efficient.

โฑ๏ธ

Point-in-Time Recovery

Restore to any moment, combining backups + transaction logs.

๐Ÿ”„

Backup Tools

clickhouse-backup for easy management, replication for HA.

Backup Strategies Comparison

Strategy Speed Storage Recovery Time Best For
Full Backup Slow High Fast Complete protection, weekly backups
Incremental Fast Low Medium Daily backups, cost reduction
Differential Fast Medium Medium Balanced approach
PITR Variable Medium Very Fast Production, disaster recovery
Replication Real-time 2x per shard Instant High availability

Why You Need Multiple Strategies

Disaster Recovery

  • Hardware failures (disk crash)
  • Data center outages
  • Accidental deletes (human error)
  • Ransomware attacks
  • Corrupted data

Business Continuity

  • Minimize data loss (RTO/RPO)
  • Enable quick recovery
  • Compliance requirements
  • Geographic redundancy
  • Testing/staging environments

Backup Architecture Diagram

ClickHouse Backup Pipeline

ClickHouse Cluster (Production Data)
โ†“
clickhouse-backup Tool
โ†“
Local Storage
Fast Access
48-hour retention
โ†’
S3/Cloud Storage
Geographic Redundancy
90-day retention
โ†’
Glacier Archive
Long-term Storage
7-year retention

Full vs Incremental Backup Flow

Full Backup

Day 1: Full Backup (100GB)
โ†“
Day 2: Full Backup (102GB)
โ†“
Day 3: Full Backup (105GB)
Total Storage: 307GB
Backup Time: ~3 hours each
Recovery: Fast (single backup)

Incremental Backup

Day 1: Full Backup (100GB)
โ†“
Day 2: +2GB changes
โ†“
Day 3: +3GB changes
Total Storage: 105GB
Backup Time: ~10 min each
Recovery: Slower (chain restore)

Point-in-Time Recovery Timeline

PITR Workflow

Sunday 00:00
Full Backup
โ†’
Mon-Sat
Incremental + Logs
โ†’
Wed 14:30
Disaster!
โ†“ RECOVERY โ†“
Recovery Steps:
1. Restore Sunday Full Backup โ†’ Base State
2. Apply Mon Incremental โ†’ +changes
3. Apply Tue Incremental โ†’ +changes
4. Apply Wed Logs up to 14:29:59 โ†’ Exact Recovery Point
โœ… Result: Data recovered to Wed 14:29:59 (1 second before disaster)

Restore Procedure Flowchart

1. Detect Failure / Data Loss
โ†“
2. Identify Last Good Backup
โ†“
3. Download from S3 (if needed)
โ†“
4. Restore Schema (Metadata)
โ†“
5. Restore Data (Parts)
โ†“
6. Apply Incremental Changes
โ†“
7. Verify Data Integrity
โ†“
8. Resume Operations โœ…

Backup Architecture Options

Local Backup

Pros: Fast, simple, no external dependencies. Cons: Vulnerable to single-node failure.

Backup Server โ†’ Local Disk (Fast)

Network Storage (NFS/SMB)

Pros: Shared storage, centralized. Cons: Network bottleneck, single point of failure.

ClickHouse Cluster โ†’ NFS/SMB โ†’ Backup Storage

S3/Cloud Storage

Pros: Highly available, geographic redundancy, scalable. Cons: Network bandwidth, latency, cost.

ClickHouse Cluster โ†’ S3/GCS/Azure Blob โ†’ Versioning + Lifecycle

Hybrid Multi-Tier

Recommended: Local + S3 with tiering. Daily to local, weekly to S3.

Cluster โ†’ Daily Local (Fast Recovery) + Weekly S3 (Long-term retention)
๐Ÿš€ Quick Start: Your First Backup

1. Install clickhouse-backup Tool

Ubuntu/Debian

sudo apt-get install -y clickhouse-backup

# Verify installation
clickhouse-backup version

macOS

brew install clickhouse-backup

# Verify installation
clickhouse-backup version

2. Create Your First Full Backup

3. Verify Backup

# Get backup details
sudo clickhouse-backup details 20260122_100000

# Check backup size
sudo du -sh /var/lib/clickhouse/backups/

4. Restore from Backup

5. Basic Scheduling with Cron

๐Ÿ’ป Commands Reference

Backup Commands

Upload Backups to S3

Restore Commands

Native ClickHouse Backup Commands

System Monitoring

โœจ Best Practices

1. Backup Strategy Design

โŒ Risky

Problem: Data center fire = total data loss

โœ… Recommended

Benefit: Protected against multiple failure modes

2. 3-2-1 Backup Rule

Industry Best Practice: 3-2-1

  • 3 copies: Original data + 2 backup copies
  • 2 media types: Local disk + Cloud storage (S3)
  • 1 offsite: One copy in different geographic region
Production DB (Local)
  โ†“
Daily Backup (Local SSD) โ†’ 48 hours retention
Daily Backup (S3) โ†’ 90 days retention
Monthly Archive (Glacier) โ†’ 7 years retention

3. Backup Window Planning

โŒ Bad

Problem: Users experience slowness

โœ… Good

Benefit: Zero impact on users

4. Retention and Lifecycle

5. Point-in-Time Recovery (PITR) Setup

6. Testing Backups Regularly

โš ๏ธ Critical: A backup is useless if it can't be restored!

  • Monthly test: Restore full backup to staging environment
  • Verify data integrity: Compare checksums
  • Document recovery time: Measure RTO
  • Test selective restore: Restore single table/database

7. Replication for HA

8. Backup Monitoring and Alerting

๐ŸŽฏ When to Use Each Backup Strategy

Full Backups

Use when:

  • You need complete data copies
  • Recovery speed is critical
  • Database is small (< 500GB)
  • Storage is not constrained
  • Weekly or monthly frequency

Incremental Backups

Use when:

  • Data changes frequently
  • Storage space is limited
  • Daily or hourly frequency
  • You need cost efficiency
  • Database is large (> 1TB)

Replication (Not Backup)

Use when:

  • You need instant failover
  • High availability is critical
  • No single node can fail
  • Read replicas needed
  • Disaster recovery required

Note: Replication protects against node failure, not data corruption or deletes!

Point-in-Time Recovery

Use when:

  • You need to recover to specific moment
  • Accidental deletes must be recoverable
  • Compliance requires audit trails
  • Ransomware protection needed
  • Testing against production data
๐Ÿ† Real-World Results & Case Studies
99.99%

Data Recovery Success

With proper 3-2-1 strategy and regular testing

< 4 hours

RTO (Recovery Time)

Restore 10TB from S3 backup with full verification

70%

Cost Reduction

vs traditional databases with lifecycle policies

15 min

Avg Recovery Time

For single table restore from local backup

Case Study 1: SaaS Analytics Platform

Challenge: Customer deleted entire dataset by mistake, needs instant recovery

Solution:

  • Point-in-time recovery from 6-hour-old backup
  • Merged with last 6 hours of WAL logs
  • Restored to staging, verified, then swapped

Results:

  • Recovery time: 45 minutes
  • Data loss: 0 (complete recovery)
  • Customer satisfaction: Restored before they realized the delete!

Case Study 2: Financial Services Company

Challenge: Ransomware attack affects production cluster

Solution:

  • Detected attack via S3 backup versioning
  • Activated offline backup on Glacier
  • Restored to new cluster in different AWS region

Results:

  • RTO: 2 hours (incident to recovery)
  • Zero ransomware payload impact
  • Compliance audit passed
  • Business continuity: Full

Case Study 3: Real-Time Analytics Company

Challenge: Balance daily backups with ingesting 10 billion events/day

Solution:

  • Use replication for HA (instant failover)
  • Backup from secondary replica (no impact)
  • Incremental backups to S3 (efficient)
  • Full backup every Sunday to Glacier

Results:

  • Zero impact on ingest performance
  • RTO: < 5 minutes (failover)
  • RPO: < 5 seconds (replication)
  • Monthly restore tests: 100% success
๐Ÿ“‹ Production-Ready Templates

Template 1: Basic Daily Backup Script

Template 2: S3 Configuration for clickhouse-backup

Template 3: Restore Script with Verification

๐Ÿ”ฅ Advanced Patterns

1. Cross-Cluster Backup Strategy

2. Incremental Backup with Chain

3. Backup Deduplication at Scale

4. Backup Verification Pipeline

5. Parallel Backup for Large Clusters

6. Disaster Recovery Runbook

๐Ÿ“š Resources & Further Learning

๐Ÿ“˜ View in Notion

Access this module in your Notion workspace for note-taking and tracking your progress.

Open in Notion โ†’

Key Concepts Summary

RTO vs RPO

  • RTO (Recovery Time Objective): How long until you're back online
  • RPO (Recovery Point Objective): Maximum acceptable data loss (in time)

Backup Types

  • Full: Complete copy of all data
  • Incremental: Only changes since last backup
  • Differential: Changes since last full backup

Key Takeaways from Module 7

  • โœ… Implement 3-2-1 backup rule: 3 copies, 2 media types, 1 offsite
  • โœ… Use clickhouse-backup for easy backup management
  • โœ… Test backups monthly - a backup that can't be restored is useless
  • โœ… Combine backups with replication for HA + disaster recovery
  • โœ… Use S3 lifecycle policies to manage long-term retention efficiently
  • โœ… Automate backup process with cron and monitoring
  • โœ… Document RTO/RPO requirements and measure actual recovery time
  • โœ… Plan backup windows during off-peak hours to minimize impact

Next Steps After This Module

You now understand how to protect your ClickHouse data. The remaining modules cover:

  • Module 8: Monitoring & Observability - Keep systems running smoothly
  • Module 9: Performance Tuning - Extract maximum speed from ClickHouse

Congratulations! You've completed most of the ClickHouse knowledge transfer. You're now equipped to run production systems with confidence!

๐Ÿณ Hands-on Docker Demo for this Module

A self-contained ClickHouse stack you can run locally. Every step is reproducible; the README below walks through each concept with diagrams and measured outcomes.

cd code-examples/demos/module-7-backup
./up.sh        # bring stack up, wait for health
./run.sh       # run the demo (idempotent โ€” re-runnable)
./down.sh      # tear down + drop volumes

๐Ÿ“บ Live demo capture

Recorded with vhs: the actual terminal output from ./run.sh running on this very stack.

Module demo GIF
Animated GIF, ~566 KB. Right-click โ†’ open in new tab to view full-size.

๐Ÿ—‚๏ธ Architecture diagrams

Rendered from the README's Mermaid sources. Click any to open the source SVG full-size.

Need need a backup
Need need a backup

๐Ÿ“š ClickHouse reference visuals

Curated from the official ClickHouse documentation and engineering blog (and Altinity's docs/blog) โ€” the same diagrams the broader CH community uses to explain these concepts. Click any image to read the source.

ClickHouse disaster-recovery architecture (primary + warm standby + backups)
Altinity Docs ClickHouse disaster-recovery architecture (primary + warm standby + backups)
Object-storage-backed parts: backup is essentially a metadata snapshot
ClickHouse Blog Object-storage-backed parts: backup is essentially a metadata snapshot

๐Ÿ“š Full module reference

Module 7 โ€” Backup & Recovery

Audience: anyone whose job depends on the data not vanishing. Prerequisites: Modules 1โ€“4. Time: ~60 min reading + 30 min hands-on.

By the end you will be able to:


1. The backup options at a glance

๐Ÿ’ฌ Discuss with AI โ€” click to view prompt
Paste into ChatGPT, Claude, Gemini, or any LLM chat.
I'm studying ClickHouse and working through the module "ClickHouse Backup & Recovery". I want to deeply understand the section: "The backup options at a glance".

Here is a brief excerpt from the material I'm reading:

"""
| Mechanism                           | Time       | Portable | Cluster-aware | Best for                                        | | `ALTER TABLE โ€ฆ FREEZE`              | instant    | no       | no            | "I'm about to do something risky, snap it now."  | | `BACKUP โ€ฆ TO Disk('backups', ...)`  | seconds    | yes      | with `ON CLUSTER` | scheduled local backups; nightly cron.       | | `BACKUP โ€ฆ TO S3(...)`               | seconds-minutes | yes | with `ON CLUSTER` | production durable backups.                  | | `clickhouse-backup` (Altinity CLI)  | depends    | yes      | yes...
"""

Please explain this concept in depth. Cover:

1. **Core mechanics** โ€” how does it actually work under the hood? What data structures, algorithms, or engine internals are involved? Where is the implementation in the ClickHouse source tree (file/folder names) if you know?

2. **When to use vs avoid** โ€” what concrete workloads does this help, and when would it hurt or be wrong? Give specific scale/latency trade-offs.

3. **Comparable features in other systems** โ€” how does this compare with similar features in PostgreSQL, MySQL, BigQuery, Snowflake, Redshift, or DuckDB? Build my intuition by analogy.

4. **Common pitfalls and gotchas** โ€” what trips engineers up in production? Subtle bugs, performance traps, surprising semantics?

5. **Worked example** โ€” show me a small but realistic SQL or config example that demonstrates the concept end-to-end. Include the expected output where useful.

6. **Where to read more** โ€” a short list of authoritative pointers (CH docs, blog posts, talks, source-code files).

Assume I have solid SQL fundamentals but I'm new to ClickHouse internals. Be technical but pragmatic; avoid marketing language.
Mechanism Time Portable Cluster-aware Best for
ALTER TABLE โ€ฆ FREEZE instant no no "I'm about to do something risky, snap it now."
BACKUP โ€ฆ TO Disk('backups', ...) seconds yes with ON CLUSTER scheduled local backups; nightly cron.
BACKUP โ€ฆ TO S3(...) seconds-minutes yes with ON CLUSTER production durable backups.
clickhouse-backup (Altinity CLI) depends yes yes full ops layer: retention, S3 lifecycle, scheduling.

2. FREEZE โ€” hardlinked instant snapshots

๐Ÿ’ฌ Discuss with AI โ€” click to view prompt
Paste into ChatGPT, Claude, Gemini, or any LLM chat.
I'm studying ClickHouse and working through the module "ClickHouse Backup & Recovery". I want to deeply understand the section: "FREEZE โ€” hardlinked instant snapshots".

Here is a brief excerpt from the material I'm reading:

"""
What it actually does: - **Hardlinks**, not copies. Constant time, zero extra disk while the source parts still exist. - Once a part is merged away, the hardlink in `shadow/` is the *only* remaining reference โ€” at which point the inode survives until you delete the shadow dir. - Recovery: copy the hardlinks somewhere safe, then re-import via `ALTER TABLE โ€ฆ ATTACH PART`. > **FREEZE is local-only.** It doesn't help against host loss. Use it > for "I'm about to do something I might regret" โ€” not as your DR plan.
"""

Please explain this concept in depth. Cover:

1. **Core mechanics** โ€” how does it actually work under the hood? What data structures, algorithms, or engine internals are involved? Where is the implementation in the ClickHouse source tree (file/folder names) if you know?

2. **When to use vs avoid** โ€” what concrete workloads does this help, and when would it hurt or be wrong? Give specific scale/latency trade-offs.

3. **Comparable features in other systems** โ€” how does this compare with similar features in PostgreSQL, MySQL, BigQuery, Snowflake, Redshift, or DuckDB? Build my intuition by analogy.

4. **Common pitfalls and gotchas** โ€” what trips engineers up in production? Subtle bugs, performance traps, surprising semantics?

5. **Worked example** โ€” show me a small but realistic SQL or config example that demonstrates the concept end-to-end. Include the expected output where useful.

6. **Where to read more** โ€” a short list of authoritative pointers (CH docs, blog posts, talks, source-code files).

Assume I have solid SQL fundamentals but I'm new to ClickHouse internals. Be technical but pragmatic; avoid marketing language.
ALTER TABLE m7.transactions FREEZE WITH NAME 'demo_snap';

What it actually does:

/var/lib/clickhouse/data/m7/transactions/
โ”œโ”€โ”€ 202601_1_1_0/
โ”‚   โ”œโ”€โ”€ columns.txt
โ”‚   โ”œโ”€โ”€ ... (data)
โ””โ”€โ”€ ...

/var/lib/clickhouse/shadow/demo_snap/
โ””โ”€โ”€ data/m7/transactions/
    โ”œโ”€โ”€ 202601_1_1_0/   โ† hardlinks to the same inodes
    โ””โ”€โ”€ ...

FREEZE is local-only. It doesn't help against host loss. Use it for "I'm about to do something I might regret" โ€” not as your DR plan.


3. The BACKUP / RESTORE SQL

๐Ÿ’ฌ Discuss with AI โ€” click to view prompt
Paste into ChatGPT, Claude, Gemini, or any LLM chat.
I'm studying ClickHouse and working through the module "ClickHouse Backup & Recovery". I want to deeply understand the section: "The BACKUP / RESTORE SQL".

Here is a brief excerpt from the material I'm reading:

"""
(no excerpt โ€” section heading was "The BACKUP / RESTORE SQL")
"""

Please explain this concept in depth. Cover:

1. **Core mechanics** โ€” how does it actually work under the hood? What data structures, algorithms, or engine internals are involved? Where is the implementation in the ClickHouse source tree (file/folder names) if you know?

2. **When to use vs avoid** โ€” what concrete workloads does this help, and when would it hurt or be wrong? Give specific scale/latency trade-offs.

3. **Comparable features in other systems** โ€” how does this compare with similar features in PostgreSQL, MySQL, BigQuery, Snowflake, Redshift, or DuckDB? Build my intuition by analogy.

4. **Common pitfalls and gotchas** โ€” what trips engineers up in production? Subtle bugs, performance traps, surprising semantics?

5. **Worked example** โ€” show me a small but realistic SQL or config example that demonstrates the concept end-to-end. Include the expected output where useful.

6. **Where to read more** โ€” a short list of authoritative pointers (CH docs, blog posts, talks, source-code files).

Assume I have solid SQL fundamentals but I'm new to ClickHouse internals. Be technical but pragmatic; avoid marketing language.

This is the modern, portable way. Targets a registered "backup destination": a local disk, an S3 bucket, or an HTTP endpoint.

Configure a destination

The destination must be in the server config:

<storage_configuration>
    <disks>
        <backups>
            <type>local</type>
            <path>/var/lib/clickhouse/backups/</path>
        </backups>
    </disks>
</storage_configuration>

<backups>
    <allowed_disk>backups</allowed_disk>
    <allowed_path>/var/lib/clickhouse/backups/</allowed_path>
</backups>

Without <backups><allowed_disk> ClickHouse refuses any BACKUP / RESTORE command. This is a safety net.

Full backup โ†’ restore

BACKUP TABLE m7.transactions TO Disk('backups', 'transactions_disk_v1.zip');

-- Verify what got written
SELECT id, name, status, total_size, num_files
FROM system.backups WHERE name LIKE '%transactions_disk_v1%';

-- Drop and restore
DROP TABLE m7.transactions;
RESTORE TABLE m7.transactions FROM Disk('backups', 'transactions_disk_v1.zip');
SELECT count() FROM m7.transactions;

Async backup

For tables larger than your HTTP timeout:

BACKUP TABLE m7.transactions
TO Disk('backups', 'transactions_async.zip')
SETTINGS async = 1;

-- Poll
SELECT status FROM system.backups
WHERE name LIKE '%transactions_async%' ORDER BY start_time DESC LIMIT 1;
-- Wait until it's BACKUP_CREATED.

Incremental backup

Reference the previous full as base_backup. Only changed parts are written.

-- Full
BACKUP TABLE t TO Disk('backups', 't_full.zip');

-- New rows...
INSERT INTO t SELECT ...;

-- Incremental
BACKUP TABLE t
TO Disk('backups', 't_inc_v2.zip')
SETTINGS base_backup = Disk('backups', 't_full.zip');

-- Restore: just point at the most recent incremental;
-- CH walks the chain back to the base automatically.
RESTORE TABLE t FROM Disk('backups', 't_inc_v2.zip');

The same setting works against S3 โ€” see queries-incremental-s3.sql for the runnable version. base_backup takes a full destination spec, not a name:

BACKUP TABLE m7.transactions
TO S3('http://m7-minio:9000/clickhouse-backups/txn_inc_v2', 'minioadmin', 'minioadmin')
SETTINGS base_backup = S3('http://m7-minio:9000/clickhouse-backups/txn_inc_base', 'minioadmin', 'minioadmin');

Reading the result

system.backups distinguishes what a backup contains from what it stored. This is the pair to show people:

SELECT name, base_backup_name, num_files, num_entries,
       formatReadableSize(total_size)      AS logical_size,
       formatReadableSize(compressed_size) AS actually_written
FROM system.backups ORDER BY start_time;
backup base num_files num_entries logical written
txn_inc_base โ€” 62 55 27.69 MiB 27.70 MiB
txn_inc_v2 txn_inc_base 74 9 30.52 MiB 2.84 MiB

74 files visible, 9 written. In the bucket that's 56 objects / 28 MiB for the base against 10 objects / 2.8 MiB for the incremental, and the incremental's data/m7/transactions/ holds exactly one part directory (202602_4_4_0).

Dedup is at part granularity. Append-only partitioned tables incremental beautifully. A table that rewrites parts โ€” heavy merges, a mutation, a re-inserted partition โ€” can produce an "incremental" nearly the size of a full, because a rewritten part is a new part.

The chain is a hard dependency

Restoring points at the newest incremental and ClickHouse walks backwards. Delete the base, though, and every incremental behind it is scrap:

Code: 599. DB::Exception: Backup S3('.../txn_inc_base', ...) not found.
           (BACKUP_NOT_FOUND)

No partial recovery, and no warning when you delete it โ€” the bucket is happy to let you. Retention must expire a base together with its dependants, or take a fresh full before expiring the old one. This is the usual way teams find out their backups were worthless, and the best argument for section 5's tooling over a hand-rolled cron job.

Backup specific partitions

BACKUP TABLE t
PARTITIONS '202601', '202602'
TO Disk('backups', 't_jan_feb.zip');

Useful for "back up just the changed month".

BACKUP ON CLUSTER

For a Replicated table on a cluster, BACKUP ON CLUSTER coordinates across replicas so the snapshot is consistent:

BACKUP TABLE analytics.page_views_local
ON CLUSTER clickhouse_cluster
TO Disk('backups', 'page_views.zip');

Each replica writes to its local Disk('backups', ...) โ€” so for cluster backups you typically point at S3 instead, where every replica writes to the same bucket.


4. S3 backups (the production path)

๐Ÿ’ฌ Discuss with AI โ€” click to view prompt
Paste into ChatGPT, Claude, Gemini, or any LLM chat.
I'm studying ClickHouse and working through the module "ClickHouse Backup & Recovery". I want to deeply understand the section: "S3 backups (the production path)".

Here is a brief excerpt from the material I'm reading:

"""
Argument layout: `S3('<endpoint>/<bucket>/<key-prefix>', '<access_key>', '<secret_key>')`. The endpoint can be AWS S3, MinIO, GCS S3-compat, R2, etc. What MinIO actually receives: The format is *part-level*. That means: - Incremental backups across S3 share parts (no double-copy). - A reasonably-equipped human can extract data by hand if needed. ### Restoring from S3
"""

Please explain this concept in depth. Cover:

1. **Core mechanics** โ€” how does it actually work under the hood? What data structures, algorithms, or engine internals are involved? Where is the implementation in the ClickHouse source tree (file/folder names) if you know?

2. **When to use vs avoid** โ€” what concrete workloads does this help, and when would it hurt or be wrong? Give specific scale/latency trade-offs.

3. **Comparable features in other systems** โ€” how does this compare with similar features in PostgreSQL, MySQL, BigQuery, Snowflake, Redshift, or DuckDB? Build my intuition by analogy.

4. **Common pitfalls and gotchas** โ€” what trips engineers up in production? Subtle bugs, performance traps, surprising semantics?

5. **Worked example** โ€” show me a small but realistic SQL or config example that demonstrates the concept end-to-end. Include the expected output where useful.

6. **Where to read more** โ€” a short list of authoritative pointers (CH docs, blog posts, talks, source-code files).

Assume I have solid SQL fundamentals but I'm new to ClickHouse internals. Be technical but pragmatic; avoid marketing language.
BACKUP TABLE m7.transactions
TO S3(
    'http://m7-minio:9000/clickhouse-backups/transactions_s3_v1',
    'minioadmin',
    'minioadmin'
);

Argument layout: S3('<endpoint>/<bucket>/<key-prefix>', '<access_key>', '<secret_key>'). The endpoint can be AWS S3, MinIO, GCS S3-compat, R2, etc.

What MinIO actually receives:

clickhouse-backups/
โ””โ”€โ”€ transactions_s3_v1/
    โ”œโ”€โ”€ .backup           โ† manifest (JSON-ish)
    โ”œโ”€โ”€ data/
    โ”‚   โ””โ”€โ”€ m7/transactions/
    โ”‚       โ””โ”€โ”€ <part_name>/
    โ”‚           โ”œโ”€โ”€ columns.txt
    โ”‚           โ”œโ”€โ”€ checksums.txt
    โ”‚           โ””โ”€โ”€ ... .bin / .mrk2
    โ””โ”€โ”€ metadata/
        โ””โ”€โ”€ m7/
            โ””โ”€โ”€ transactions.sql

The format is part-level. That means: - Incremental backups across S3 share parts (no double-copy). - A reasonably-equipped human can extract data by hand if needed.

Restoring from S3

RESTORE TABLE m7.transactions
FROM S3(
    'http://m7-minio:9000/clickhouse-backups/transactions_s3_v1',
    'minioadmin',
    'minioadmin'
);

5. clickhouse-backup โ€” the operations layer

๐Ÿ’ฌ Discuss with AI โ€” click to view prompt
Paste into ChatGPT, Claude, Gemini, or any LLM chat.
I'm studying ClickHouse and working through the module "ClickHouse Backup & Recovery". I want to deeply understand the section: "clickhouse-backup โ€” the operations layer".

Here is a brief excerpt from the material I'm reading:

"""
(no excerpt โ€” section heading was "clickhouse-backup โ€” the operations layer")
"""

Please explain this concept in depth. Cover:

1. **Core mechanics** โ€” how does it actually work under the hood? What data structures, algorithms, or engine internals are involved? Where is the implementation in the ClickHouse source tree (file/folder names) if you know?

2. **When to use vs avoid** โ€” what concrete workloads does this help, and when would it hurt or be wrong? Give specific scale/latency trade-offs.

3. **Comparable features in other systems** โ€” how does this compare with similar features in PostgreSQL, MySQL, BigQuery, Snowflake, Redshift, or DuckDB? Build my intuition by analogy.

4. **Common pitfalls and gotchas** โ€” what trips engineers up in production? Subtle bugs, performance traps, surprising semantics?

5. **Worked example** โ€” show me a small but realistic SQL or config example that demonstrates the concept end-to-end. Include the expected output where useful.

6. **Where to read more** โ€” a short list of authoritative pointers (CH docs, blog posts, talks, source-code files).

Assume I have solid SQL fundamentals but I'm new to ClickHouse internals. Be technical but pragmatic; avoid marketing language.

Runnable in this demo: backup-tool.sh, configured by configs/clickhouse-backup.yml.

How it actually works

It does not issue BACKUP TO S3 on the server's behalf. It runs ALTER TABLE ... FREEZE, reads the resulting hardlinks out of /var/lib/clickhouse/shadow/, and uploads them itself. Two consequences:

Commands

# Two-phase: snapshot now (cheap, instant), ship later
clickhouse-backup create        nightly-2026-07-26
clickhouse-backup upload        nightly-2026-07-26

# Or both at once
clickhouse-backup create_remote nightly-2026-07-26

# Incremental โ€” diff against a REMOTE backup by name
clickhouse-backup create_remote --diff-from-remote=nightly-2026-07-26 \
                                inc-2026-07-27
#   --diff-from  is the local-only equivalent

# Recovery
clickhouse-backup restore_remote inc-2026-07-27
clickhouse-backup restore_remote --schema inc-2026-07-27     # schema only
clickhouse-backup restore_remote --restore-table-mapping='transactions:transactions_verify' \
                                 inc-2026-07-27              # restore beside the live table

# Maintenance
clickhouse-backup list local
clickhouse-backup list remote
clickhouse-backup delete remote nightly-2026-04-01
clickhouse-backup print-config          # merged config incl. env overrides
clickhouse-backup default-config        # every key with its default

What incremental looks like

list remote shows the dependency in a required column:

full-20260726-114022   remote                          all:30.58MiB, ...
inc-20260726-114022    remote  +full-20260726-114022   all:2.16MiB,  ...

Measured on the demo table: full upload 30.58 MiB โ†’ incremental upload 2.16 MiB. But restoring the incremental with nothing cached locally downloads 32.67 MiB:

downloadDiffParts  table=m7.transactions  diff_parts=4  diff_bytes=30.52MiB
download           download_size=32.67MiB

Backup cost scales with what changed; restore cost scales with the whole dataset. Size your RTO against the second number.

Config keys that matter

Full annotated file in configs/clickhouse-backup.yml. The ones people get wrong:

Key Why it matters
general.upload_by_part: true What makes --diff-from-remote cheap. Off = every backup is silently a full. Default true โ€” don't "tidy" it away.
general.backups_to_keep_local / _remote Retention. Default 0 = keep forever, which is how disks and S3 bills fill up.
s3.force_path_style: true Required for MinIO (bucket in path, not in hostname). Leave false for real AWS S3.
s3.disable_ssl: true Only because the demo MinIO is plain HTTP. Never in production.
s3.compression_format: tar tar = package, don't compress. .bin files are already codec-compressed; gzip/zstd burns CPU for near-zero gain.
clickhouse.log_sql_queries Defaults to true and logs every internal query at INF. Set false or output is unreadable.
general.upload_max_bytes_per_second Throttle so backups don't starve query I/O. 0 = unlimited.
clickhouse.host + port: 9000 Native protocol. Pointing at 8123 fails confusingly.

Every key is overridable by env var (SECTION_KEY uppercased โ€” S3_ACCESS_KEY, CLICKHOUSE_PASSWORD). That is how you keep credentials out of the YAML in production.

Gotcha: DROP TABLE ... SYNC before a tool restore

A plain DROP TABLE on an Atomic database parks the data directory for database_atomic_delay_before_drop_table_sec (default 480s) so UNDROP TABLE can work. clickhouse-backup recreates the table with its original UUID, so it collides with the parked directory:

Code: 57. Directory for table data store/ae2/ae215ea4-.../ already exists

Native RESTORE never hits this โ€” it assigns a fresh UUID. Only the tool preserves them. Use DROP TABLE ... SYNC, or --restore-table-mapping to a different name. Cleaning up after the collision means deleting metadata_dropped/ entries and store/ dirs by hand.

What it adds over raw SQL

Repo: https://github.com/Altinity/clickhouse-backup.


6. Partition operations โ€” the cheap surrogate

๐Ÿ’ฌ Discuss with AI โ€” click to view prompt
Paste into ChatGPT, Claude, Gemini, or any LLM chat.
I'm studying ClickHouse and working through the module "ClickHouse Backup & Recovery". I want to deeply understand the section: "Partition operations โ€” the cheap surrogate".

Here is a brief excerpt from the material I'm reading:

"""
For tables you partition by date: `ATTACH PARTITION FROM` is the single most useful trick for "promote a staging table into the live table" โ€” fully atomic, no rewrites.
"""

Please explain this concept in depth. Cover:

1. **Core mechanics** โ€” how does it actually work under the hood? What data structures, algorithms, or engine internals are involved? Where is the implementation in the ClickHouse source tree (file/folder names) if you know?

2. **When to use vs avoid** โ€” what concrete workloads does this help, and when would it hurt or be wrong? Give specific scale/latency trade-offs.

3. **Comparable features in other systems** โ€” how does this compare with similar features in PostgreSQL, MySQL, BigQuery, Snowflake, Redshift, or DuckDB? Build my intuition by analogy.

4. **Common pitfalls and gotchas** โ€” what trips engineers up in production? Subtle bugs, performance traps, surprising semantics?

5. **Worked example** โ€” show me a small but realistic SQL or config example that demonstrates the concept end-to-end. Include the expected output where useful.

6. **Where to read more** โ€” a short list of authoritative pointers (CH docs, blog posts, talks, source-code files).

Assume I have solid SQL fundamentals but I'm new to ClickHouse internals. Be technical but pragmatic; avoid marketing language.

For tables you partition by date:

-- Snapshot a partition (still hardlinks under shadow/)
ALTER TABLE t FREEZE PARTITION '202601';

-- Detach a partition (moves to detached/, queries don't see it)
ALTER TABLE t DETACH PARTITION '202601';

-- Re-attach when ready
ALTER TABLE t ATTACH PARTITION '202601';

-- Drop irrevocably (use with caution; ATTACH FROM detached still possible briefly)
ALTER TABLE t DROP PARTITION '202601';

-- Move a partition between two same-schema tables
ALTER TABLE t_archive ATTACH PARTITION '202601' FROM t;

ATTACH PARTITION FROM is the single most useful trick for "promote a staging table into the live table" โ€” fully atomic, no rewrites.


7. The hands-on demo

๐Ÿ’ฌ Discuss with AI โ€” click to view prompt
Paste into ChatGPT, Claude, Gemini, or any LLM chat.
I'm studying ClickHouse and working through the module "ClickHouse Backup & Recovery". I want to deeply understand the section: "The hands-on demo".

Here is a brief excerpt from the material I'm reading:

"""
### What you get ### Container map | Service     | Container         | Host ports         | | ClickHouse  | `m7-clickhouse`   | 8123, 9000         | | MinIO       | `m7-minio`        | 9100 (S3), 9101 (console) | | Bootstrap   | `m7-minio-init`   | (one-shot)         | | Backup tool | `m7-backup-tool`  | (idle; `docker exec` into it) | MinIO console: <http://localhost:9101>, login `minioadmin` / `minioadmin`. From your host the S3 API is `localhost:9100`; from inside `m7-net` it is `m7-minio:9000`. Same MinIO, opposite sides of the port mapping โ€” that is why the SQL says `9000` and your browse...
"""

Please explain this concept in depth. Cover:

1. **Core mechanics** โ€” how does it actually work under the hood? What data structures, algorithms, or engine internals are involved? Where is the implementation in the ClickHouse source tree (file/folder names) if you know?

2. **When to use vs avoid** โ€” what concrete workloads does this help, and when would it hurt or be wrong? Give specific scale/latency trade-offs.

3. **Comparable features in other systems** โ€” how does this compare with similar features in PostgreSQL, MySQL, BigQuery, Snowflake, Redshift, or DuckDB? Build my intuition by analogy.

4. **Common pitfalls and gotchas** โ€” what trips engineers up in production? Subtle bugs, performance traps, surprising semantics?

5. **Worked example** โ€” show me a small but realistic SQL or config example that demonstrates the concept end-to-end. Include the expected output where useful.

6. **Where to read more** โ€” a short list of authoritative pointers (CH docs, blog posts, talks, source-code files).

Assume I have solid SQL fundamentals but I'm new to ClickHouse internals. Be technical but pragmatic; avoid marketing language.

What you get

docker-compose.yml                 m7-clickhouse + m7-minio + m7-minio-init + m7-backup-tool
configs/clickhouse-config.xml      includes <backups> + <storage_configuration>
configs/default-user.xml           opens the default-user ACL to the docker network
configs/clickhouse-backup.yml      annotated clickhouse-backup config
setup.sql ยท queries.sql ยท queries-s3.sql ยท queries-incremental-s3.sql ยท extras.sql
backup-tool.sh                     clickhouse-backup full + incremental + DR restore
up.sh ยท run.sh ยท down.sh

Container map

Service Container Host ports
ClickHouse m7-clickhouse 8123, 9000
MinIO m7-minio 9100 (S3), 9101 (console)
Bootstrap m7-minio-init (one-shot)
Backup tool m7-backup-tool (idle; docker exec into it)

MinIO console: http://localhost:9101, login minioadmin / minioadmin. From your host the S3 API is localhost:9100; from inside m7-net it is m7-minio:9000. Same MinIO, opposite sides of the port mapping โ€” that is why the SQL says 9000 and your browser says 9101.

m7-backup-tool shares the m7_data volume with ClickHouse because clickhouse-backup reads the data directory directly. It idles on sleep infinity; drive it with docker exec m7-backup-tool clickhouse-backup โ€ฆ or just run ./backup-tool.sh.

The default user's ACL is widened in configs/default-user.xml โ€” the stock image restricts it to 127.0.0.1, which the backup tool (a separate container) cannot satisfy. Same fix modules 3 and 4 needed for distributed queries.

Execution flow โ€” what runs, in order

# Step What happens
0 self-bootstrap up.sh brings up CH + MinIO + the bucket bootstrap (m7-minio-init creates clickhouse-backups). Both share m7-net, so CH can reach http://m7-minio:9000.
1 setup.sql Creates database m7, table m7.transactions (MergeTree partitioned by month, ordered by (account_id, txn_time, txn_id)), inserts 2M synthetic rows.
2 queries.sql โ€” local-disk backup path ALTER TABLE โ€ฆ FREEZE WITH NAME 'demo_snap' (instant hardlinks under /var/lib/clickhouse/shadow/), BACKUP TABLE โ€ฆ TO Disk('backups', 'transactions_disk_v1.zip'), DROP TABLE, RESTORE TABLE โ€ฆ FROM Disk(โ€ฆ), then per-partition DETACH PARTITION '202601' + ATTACH PARTITION '202601'.
3 queries-s3.sql โ€” S3 backup path BACKUP TABLE โ€ฆ TO S3('http://m7-minio:9000/clickhouse-backups/transactions_s3_v1', 'minioadmin', 'minioadmin'), look up the backup row in system.backups, DROP TABLE, RESTORE โ€ฆ FROM S3(โ€ฆ). Verify row count returns to 2M.
4 extras.sql โ€” async + incremental BACKUP TABLE โ€ฆ SETTINGS async = 1 (returns immediately), poll loop on system.backups.status until BACKUP_CREATED. Insert 50k more rows, then BACKUP โ€ฆ SETTINGS base_backup = Disk('backups', 'transactions_disk_v1.zip') โ€” the resulting incremental zip is much smaller. DROP TABLE, RESTORE FROM Disk('backups', 'transactions_inc_v2.zip') โ€” CH walks the chain to the base. Prints notes on BACKUP ON CLUSTER.
5 queries-incremental-s3.sql โ€” incremental to S3 Full base to MinIO, insert a new February partition, then BACKUP โ€ฆ SETTINGS base_backup = S3(โ€ฆ). Compares num_files vs num_entries in system.backups (74 visible / 9 written), restores from the incremental alone, and documents the BACKUP_NOT_FOUND failure you get when the base is deleted.
6 backup-tool.sh โ€” the ops layer (run separately) clickhouse-backup create_remote, insert a March partition, create_remote --diff-from-remote, list remote (shows the +base dependency), then a genuine DR drill: delete local backups, DROP TABLE โ€ฆ SYNC, restore_remote from the incremental. Not part of run.sh โ€” invoke it yourself.

What you should observe

Step Outcome
FREEZE /var/lib/clickhouse/shadow/demo_snap/ exists with hardlinks; same inodes as live data.
BACKUP TO Disk Zip file under /var/lib/clickhouse/backups/; system.backups.status = 'BACKUP_CREATED'.
DROP + RESTORE Row count returns to 2,000,000.
Partition detach/attach Row count drops then returns; no data rewrite.
BACKUP TO S3 Visible in MinIO console at http://localhost:9101; nested under clickhouse-backups/transactions_s3_v1/.
Async backup Returns immediately; status flips through CREATING_BACKUP โ†’ BACKUP_CREATED.
Incremental total_size of transactions_inc_v2.zip โ‰ช transactions_disk_v1.zip.

8. A reasonable production schedule

๐Ÿ’ฌ Discuss with AI โ€” click to view prompt
Paste into ChatGPT, Claude, Gemini, or any LLM chat.
I'm studying ClickHouse and working through the module "ClickHouse Backup & Recovery". I want to deeply understand the section: "A reasonable production schedule".

Here is a brief excerpt from the material I'm reading:

"""
| Cadence  | What                                          | Where                              | | Daily    | Full `BACKUP ON CLUSTER` to S3                | `s3://backups/clickhouse/<env>/<date>/full` | | Hourly   | Incremental against the day's full            | `s3://.../<date>/inc-NN`            | | Weekly   | Restore drill into a sandbox cluster          | scratch S3 path; verify counts      | | 30 days  | Lifecycle to Glacier / Coldline               | bucket lifecycle rule               | > **A backup you have never restored is not a backup.** Run a restore > drill at least monthly. Mo...
"""

Please explain this concept in depth. Cover:

1. **Core mechanics** โ€” how does it actually work under the hood? What data structures, algorithms, or engine internals are involved? Where is the implementation in the ClickHouse source tree (file/folder names) if you know?

2. **When to use vs avoid** โ€” what concrete workloads does this help, and when would it hurt or be wrong? Give specific scale/latency trade-offs.

3. **Comparable features in other systems** โ€” how does this compare with similar features in PostgreSQL, MySQL, BigQuery, Snowflake, Redshift, or DuckDB? Build my intuition by analogy.

4. **Common pitfalls and gotchas** โ€” what trips engineers up in production? Subtle bugs, performance traps, surprising semantics?

5. **Worked example** โ€” show me a small but realistic SQL or config example that demonstrates the concept end-to-end. Include the expected output where useful.

6. **Where to read more** โ€” a short list of authoritative pointers (CH docs, blog posts, talks, source-code files).

Assume I have solid SQL fundamentals but I'm new to ClickHouse internals. Be technical but pragmatic; avoid marketing language.
Cadence What Where
Daily Full BACKUP ON CLUSTER to S3 s3://backups/clickhouse/<env>/<date>/full
Hourly Incremental against the day's full s3://.../<date>/inc-NN
Weekly Restore drill into a sandbox cluster scratch S3 path; verify counts
30 days Lifecycle to Glacier / Coldline bucket lifecycle rule

A backup you have never restored is not a backup. Run a restore drill at least monthly. Module 8's drill 6 exercises this end-to-end.


9. Operational SQL cheatsheet

๐Ÿ’ฌ Discuss with AI โ€” click to view prompt
Paste into ChatGPT, Claude, Gemini, or any LLM chat.
I'm studying ClickHouse and working through the module "ClickHouse Backup & Recovery". I want to deeply understand the section: "Operational SQL cheatsheet".

Here is a brief excerpt from the material I'm reading:

"""
(no excerpt โ€” section heading was "Operational SQL cheatsheet")
"""

Please explain this concept in depth. Cover:

1. **Core mechanics** โ€” how does it actually work under the hood? What data structures, algorithms, or engine internals are involved? Where is the implementation in the ClickHouse source tree (file/folder names) if you know?

2. **When to use vs avoid** โ€” what concrete workloads does this help, and when would it hurt or be wrong? Give specific scale/latency trade-offs.

3. **Comparable features in other systems** โ€” how does this compare with similar features in PostgreSQL, MySQL, BigQuery, Snowflake, Redshift, or DuckDB? Build my intuition by analogy.

4. **Common pitfalls and gotchas** โ€” what trips engineers up in production? Subtle bugs, performance traps, surprising semantics?

5. **Worked example** โ€” show me a small but realistic SQL or config example that demonstrates the concept end-to-end. Include the expected output where useful.

6. **Where to read more** โ€” a short list of authoritative pointers (CH docs, blog posts, talks, source-code files).

Assume I have solid SQL fundamentals but I'm new to ClickHouse internals. Be technical but pragmatic; avoid marketing language.
-- "What backups exist?"
SELECT id, name, status, formatReadableSize(total_size) AS size,
       num_files, start_time, end_time
FROM system.backups ORDER BY start_time DESC LIMIT 20;

-- "What's running right now?"
SELECT id, name, status, num_files, processed_files
FROM system.backups WHERE status IN ('CREATING_BACKUP','RESTORING') ;

-- "Which freezes are still on disk?"
-- (no system table; check the shadow/ dir)
-- docker exec m7-clickhouse ls /var/lib/clickhouse/shadow/

-- "Drop a stuck async backup"
SYSTEM SHUTDOWN BACKUP <backup_id>;       -- newer CH; varies by version

10. Settings worth knowing

๐Ÿ’ฌ Discuss with AI โ€” click to view prompt
Paste into ChatGPT, Claude, Gemini, or any LLM chat.
I'm studying ClickHouse and working through the module "ClickHouse Backup & Recovery". I want to deeply understand the section: "Settings worth knowing".

Here is a brief excerpt from the material I'm reading:

"""
| Setting                              | Effect                                                                | | `async = 1` on BACKUP                | Returns immediately; poll `system.backups`.                           | | `base_backup = Disk('...', 'name')`  | Make this an incremental against the named base.                      | | `compression_method = 'zstd'`        | Compress the backup file (default depends on destination).            | | `password = '...'`                   | Encrypt the backup (file destination only).                           | | `s3_max_connections`...
"""

Please explain this concept in depth. Cover:

1. **Core mechanics** โ€” how does it actually work under the hood? What data structures, algorithms, or engine internals are involved? Where is the implementation in the ClickHouse source tree (file/folder names) if you know?

2. **When to use vs avoid** โ€” what concrete workloads does this help, and when would it hurt or be wrong? Give specific scale/latency trade-offs.

3. **Comparable features in other systems** โ€” how does this compare with similar features in PostgreSQL, MySQL, BigQuery, Snowflake, Redshift, or DuckDB? Build my intuition by analogy.

4. **Common pitfalls and gotchas** โ€” what trips engineers up in production? Subtle bugs, performance traps, surprising semantics?

5. **Worked example** โ€” show me a small but realistic SQL or config example that demonstrates the concept end-to-end. Include the expected output where useful.

6. **Where to read more** โ€” a short list of authoritative pointers (CH docs, blog posts, talks, source-code files).

Assume I have solid SQL fundamentals but I'm new to ClickHouse internals. Be technical but pragmatic; avoid marketing language.
Setting Effect
async = 1 on BACKUP Returns immediately; poll system.backups.
base_backup = Disk('...', 'name') Make this an incremental against the named base.
compression_method = 'zstd' Compress the backup file (default depends on destination).
password = '...' Encrypt the backup (file destination only).
s3_max_connections Concurrency for S3 backup/restore I/O.
allow_drop_detached Allow DROP DETACHED PART (safety knob; off by default).

11. Common pitfalls

๐Ÿ’ฌ Discuss with AI โ€” click to view prompt
Paste into ChatGPT, Claude, Gemini, or any LLM chat.
I'm studying ClickHouse and working through the module "ClickHouse Backup & Recovery". I want to deeply understand the section: "Common pitfalls".

Here is a brief excerpt from the material I'm reading:

"""
| Symptom                                                                      | Cause                                                                       | Fix                                                                                              | | `Code: 605. The maximum size of file system disk is allowed for backups...`  | Backup destination not in `<allowed_disk>` / `<allowed_path>`.              | Add it to `<backups>` in config.                                                                 | | `BACKUP TO Disk(...)` works but takes forever                                | Ton...
"""

Please explain this concept in depth. Cover:

1. **Core mechanics** โ€” how does it actually work under the hood? What data structures, algorithms, or engine internals are involved? Where is the implementation in the ClickHouse source tree (file/folder names) if you know?

2. **When to use vs avoid** โ€” what concrete workloads does this help, and when would it hurt or be wrong? Give specific scale/latency trade-offs.

3. **Comparable features in other systems** โ€” how does this compare with similar features in PostgreSQL, MySQL, BigQuery, Snowflake, Redshift, or DuckDB? Build my intuition by analogy.

4. **Common pitfalls and gotchas** โ€” what trips engineers up in production? Subtle bugs, performance traps, surprising semantics?

5. **Worked example** โ€” show me a small but realistic SQL or config example that demonstrates the concept end-to-end. Include the expected output where useful.

6. **Where to read more** โ€” a short list of authoritative pointers (CH docs, blog posts, talks, source-code files).

Assume I have solid SQL fundamentals but I'm new to ClickHouse internals. Be technical but pragmatic; avoid marketing language.
Symptom Cause Fix
Code: 605. The maximum size of file system disk is allowed for backups... Backup destination not in <allowed_disk> / <allowed_path>. Add it to <backups> in config.
BACKUP TO Disk(...) works but takes forever Tons of small parts (single-row INSERTs from upstream). Optimise / batch upstream. Backup time scales with part count.
RESTORE fails with "Backup data not found" Pointed at the wrong base or chain broken. Verify system.backups knows the chain; restore from the highest layer.
FREEZE makes disk usage spike when old parts merge Hardlinks still reference old part files; merges can't reclaim. Clear shadow/ directories you no longer need.
S3 backup with self-signed MinIO fails on TLS The S3 endpoint URL uses https:// and the cert isn't trusted. Use http:// for MinIO, or mount the CA into CH and trust it.
BACKUP ON CLUSTER fails on one node That node can't reach the destination. Verify per-node connectivity (e.g. all hosts can resolve the S3 endpoint).

12. Talking points for the live session

๐Ÿ’ฌ Discuss with AI โ€” click to view prompt
Paste into ChatGPT, Claude, Gemini, or any LLM chat.
I'm studying ClickHouse and working through the module "ClickHouse Backup & Recovery". I want to deeply understand the section: "Talking points for the live session".

Here is a brief excerpt from the material I'm reading:

"""
1. **Three layers, three uses.** FREEZE for "oh wait, hold on"; BACKUP/RESTORE for routine; `clickhouse-backup` for ops scale. 2. **Backups are part-level.** Show MinIO contents; the directory tree matches the live data layout. 3. **Incrementals are nearly free** if your data is mostly append. 4. **Restore drills are the test.** Without monthly drills you don't have backups, you have hopes. 5. **Partition operations** (DETACH / ATTACH) are the secret weapon for archive workflows. 6. **`ON CLUSTER`** for replicated tables โ€” coordinated snapshot.
"""

Please explain this concept in depth. Cover:

1. **Core mechanics** โ€” how does it actually work under the hood? What data structures, algorithms, or engine internals are involved? Where is the implementation in the ClickHouse source tree (file/folder names) if you know?

2. **When to use vs avoid** โ€” what concrete workloads does this help, and when would it hurt or be wrong? Give specific scale/latency trade-offs.

3. **Comparable features in other systems** โ€” how does this compare with similar features in PostgreSQL, MySQL, BigQuery, Snowflake, Redshift, or DuckDB? Build my intuition by analogy.

4. **Common pitfalls and gotchas** โ€” what trips engineers up in production? Subtle bugs, performance traps, surprising semantics?

5. **Worked example** โ€” show me a small but realistic SQL or config example that demonstrates the concept end-to-end. Include the expected output where useful.

6. **Where to read more** โ€” a short list of authoritative pointers (CH docs, blog posts, talks, source-code files).

Assume I have solid SQL fundamentals but I'm new to ClickHouse internals. Be technical but pragmatic; avoid marketing language.
  1. Three layers, three uses. FREEZE for "oh wait, hold on"; BACKUP/RESTORE for routine; clickhouse-backup for ops scale.
  2. Backups are part-level. Show MinIO contents; the directory tree matches the live data layout.
  3. Incrementals are nearly free if your data is mostly append.
  4. Restore drills are the test. Without monthly drills you don't have backups, you have hopes.
  5. Partition operations (DETACH / ATTACH) are the secret weapon for archive workflows.
  6. ON CLUSTER for replicated tables โ€” coordinated snapshot.

13. Going deeper

๐Ÿ’ฌ Discuss with AI โ€” click to view prompt
Paste into ChatGPT, Claude, Gemini, or any LLM chat.
I'm studying ClickHouse and working through the module "ClickHouse Backup & Recovery". I want to deeply understand the section: "Going deeper".

Here is a brief excerpt from the material I'm reading:

"""
- **Module 8** โ€” DR drills, including end-to-end backup-restore over a cluster. - ClickHouse docs: <https://clickhouse.com/docs/en/operations/backup> - `clickhouse-backup`: <https://github.com/Altinity/clickhouse-backup>
"""

Please explain this concept in depth. Cover:

1. **Core mechanics** โ€” how does it actually work under the hood? What data structures, algorithms, or engine internals are involved? Where is the implementation in the ClickHouse source tree (file/folder names) if you know?

2. **When to use vs avoid** โ€” what concrete workloads does this help, and when would it hurt or be wrong? Give specific scale/latency trade-offs.

3. **Comparable features in other systems** โ€” how does this compare with similar features in PostgreSQL, MySQL, BigQuery, Snowflake, Redshift, or DuckDB? Build my intuition by analogy.

4. **Common pitfalls and gotchas** โ€” what trips engineers up in production? Subtle bugs, performance traps, surprising semantics?

5. **Worked example** โ€” show me a small but realistic SQL or config example that demonstrates the concept end-to-end. Include the expected output where useful.

6. **Where to read more** โ€” a short list of authoritative pointers (CH docs, blog posts, talks, source-code files).

Assume I have solid SQL fundamentals but I'm new to ClickHouse internals. Be technical but pragmatic; avoid marketing language.

๐Ÿ’พ ClickHouse Knowledge Transfer

Module 7 of 10 | Duration: 6-8 weeks total

Backup, Recovery & PITR - Protecting Your Data | 2026

โ† Previous: Module 6 - Query Optimization ๐Ÿ  Home Next: Module 8 - Disaster Recovery โ†’