This episode dissects how Borg works: the repository as the home of data and index, the archive as a point-in-time snapshot of a dataset, content-defined chunking as the key to deduplication, and the role of the borg binary, the repo location, and the key. You also get a subcommand map that forms the backup lifecycle.

In episode 1 we learned why Borg exists and why dedup matters. Now it is time to understand how Borg works under the hood: what a repository is, what an archive is, and how content-defined chunking produces efficient deduplication. This understanding is not just theory — when your backup misbehaves in episode 16, you will come back to this chapter.
The repository is a storage location (local or remote via SSH) that holds all of Borg's data. Internally, a repository contains:
borg check in episode 12.An archive is a "snapshot" of one dataset at one point in time — the result of a single borg create command. A single repository can hold hundreds of archives from different days, weeks, and even years. Each archive stores complete file metadata (name, permissions, timestamp, chunk list) and references to the data chunks.
The key insight: two archives that contain the same file will share the same chunks. Adding one file to a second archive does not store that file's data again — that is the source of Borg's efficiency.
To split files into chunks, Borg uses content-defined chunking (CDC) with the buzhash algorithm. Because chunk boundaries are determined by content patterns, not byte positions, shifted data does not change all chunks. By default the average chunk is around 2 MiB, and this parameter can be tuned for specific datasets (episode 18).
borg Binaryborg is a single Python binary containing many subcommands. Every operation — from creating a repo to checking integrity — goes through this subcommand. There is no daemon, no external database; just the binary and the filesystem.
A repo is written as a local path (/backup/borg) or a remote one (user@backup-host:/backup/borg). Borg detects the user@host: pattern and automatically uses SSH — including calling borg serve on the server side, as we build in episode 11.
Borg's encryption depends on a key. There are two main styles: repokey (the key is stored inside the repository, protected by a passphrase) and keyfile (the key is in a separate file). Without the correct key or passphrase, the repository is unreadable — even by the original owner of the data. Full details in episode 7.
borg init # create a repository
borg create # create an archive (backup)
borg list # list archives in the repo
borg info # archive/repo details
borg extract # restore from an archive
borg mount # mount an archive via FUSE
borg prune # delete old archives (retention)
borg compact # reclaim segment space
borg check # verify repo integrityThe order of this map is the backup lifecycle: init → create (repeated many times) → prune + compact → check. We follow that flow exactly from episode 3 to 12.
borg createAn important consequence of step 5: deleting an archive does not immediately free space. Chunks no longer referenced are only truly discarded when borg compact is run — we cover this in episode 8.
Tip
Because the index can be rebuilt from segments, "losing the index" is not the end of the world — borg check will reconstruct it. What really matters is the data segments and the encryption key. Take care of both, and your backups survive.
borg binary, repo location (local/SSH), key, and subcommands.init → create → prune/compact → check.borg compact.In episode 3 we run the first real command: repository initialization with borg init, choosing between the repokey, keyfile, and authenticated encryption modes, and setting up BORG_REPO and BORG_PASSPHRASE/BORG_PASSCOMMAND correctly.