Project hosts

How snapshots and backups work

How snapshots and backups work, their default schedule, what they guarantee, and what makes a backup slow.

Three layers of history

CoCalc keeps three different kinds of history for a project. They answer different questions, so it helps to know which one you need.

Layer Where it lives What it is for
Edit history (TimeTravel) Stored separately on the project host Every saved change to a document, file by file
Snapshots ~/.snapshots on the project host Fast, read-only, point-in-time copies of HOME
Backups Encrypted, off-host object storage Recovery when the host or its disk is gone, moves, archives

Snapshots are cheap and frequent, but they live on the same disk as the project. Backups are the copy that survives losing the host.

Default schedule

By default CoCalc keeps snapshots taken every 15 minutes (the newest 4), plus 7 daily, 4 weekly and 2 monthly snapshots. Backups default to 1 daily, 3 weekly and 4 monthly. A new snapshot or backup is only made when something changed. Project owners can change these schedules, and can allow collaborators to manage them.

Scheduled snapshots and backups are background work. They run with constrained CPU and I/O to reduce interference with running projects, which also means they can be delayed when the host is busy. CoCalc tracks overdue snapshots and backups and works through them as the host frees up.

How a backup is made

  1. CoCalc first captures the project's separately stored edit history, then takes a temporary read-only btrfs snapshot of the project's HOME and adds that captured history to it. HOME is one consistent moment in time even while you keep working; the edit history can be slightly older than the files, and a restore reconciles the two.
  2. The backup tool (rustic) walks the snapshot and compares every file with the previous backup.
  3. A file whose path, size, modification time and change time (ctime) all match the previous backup is unchanged and is not read again.
  4. Every other file is read in full, split into content-defined chunks, and each chunk is identified by its hash. Chunks already in the backup repository are not stored again (deduplication), so only genuinely new data is uploaded.
  5. Everything is encrypted before it leaves the host. The temporary snapshot is deleted afterwards.

What you can rely on

What is not in a backup

What makes a backup slow

The work a backup does depends on how much data is new or changed by path, not on how much disk the project uses. These patterns are cheap on disk but expensive to back up, because every file at a new path is read in full before deduplication can discard it:

Deleting obsolete copies, and keeping only the releases or worktrees you actually need, makes backups much faster. A project's disk usage can be far smaller than what a backup has to read, because copies that share disk blocks are counted once.

Restoring

Use a snapshot to recover recent files quickly, and a backup when the snapshot is gone or you need an older version. Recover research files and environments explains how to choose the smallest recovery operation, and Project host storage, backups, and snapshots covers restore behaviour and the file-size limit.

Agent notes