An unprotected repository is just an easy ransomware target. This episode covers authenticated encryption as the base layer, append-only mode to prevent history deletion, and the SSH lock with a restricted command. You will learn to protect backups from attacks that target the data itself.

A backup is the last line of defense when a server is attacked — but if the backup repository is attacked too, that line disappears. Modern ransomware no longer targets just data; it targets backups so the victim has no way out. Episode 13 turns your repository from an easy target into a fortress: authenticated encryption, append-only mode, and strict access control.
Two modes from episodes 3 and 7 are relevant here:
Both modes provide integrity: an altered chunk will not pass verification. This matters because it ensures that the backup you restore is truly the backup you made.
Note
Encryption protects confidentiality; integrity protects authenticity. They are different and both are needed. Authenticated without encryption may be used only when the physical storage is already encrypted — do not make it a habit for repos with sensitive data.
An append-only repository only allows adding (appending) new data — no modification or deletion of existing segments. This counters the classic ransomware scenario: an attacker who gains client access to the repo (e.g. through the backed-up host) cannot delete the backup history to force a restore from an already-damaged version.
Borg 1.2 brought a significant improvement to append-only: repositories can now run in this mode more strictly, and server-side append-only (borg serve --append-only) became the primary recommendation — not just a client flag that can be worked around.
At initialization:
borg init --encryption=repokey-blake2 --append-only /backup/borgOr set it on an existing repository:
borg config /backup/borg append_only 1For a remote repo, lock append-only on the server side so the client cannot turn it off:
command="borg serve --restrict-to-path /srv/borg --restrict-to-repository /srv/borg/backup --append-only",restrict,no-pty ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA... borg-backupWith this pattern, the client cannot run prune/delete — it can only add. If you use borgmatic, prune exceptions must be arranged on the server side by temporarily removing --append-only from authorized_keys (or via a dedicated maintenance repo).
Episode 11 already introduced command= in authorized_keys. Here we see it as a repository security component, not just convenience:
command="borg serve --restrict-to-path /srv/borg --restrict-to-repository /srv/borg/backup",restrict,no-pty ssh-ed25519 AAAA... borg-backup--restrict-to-path: borg serve cannot read files outside /srv/borg.--restrict-to-repository: only one repository is served.restrict: disables any SSH forwarding.To limit the damage if the repository is flooded with data (malicious or accidental), set a per-repo quota:
borg config /backup/borg storage_quota 500GWhen the quota is reached, create is rejected — backups do not silently stop, but there is a clear, alertable limit.
Warning
Append-only protects history from deletion, but it does not protect from encryption if an attacker obtains the key/passphrase. A strong passphrase + disciplined key management (episode 7) are non-negotiable parts of this scenario.
--append-only flag is only used at borg create time, another client (or an attacker with access) can still prune. Lock it on the server with borg serve --append-only.borg serve --append-only.command="borg serve --restrict-to-path ..." limits the blast radius.In episode 14 we apply all of this at a larger scale: hardening & multi-host — one repository per host/team, key isolation, access monitoring, off-site backups on different hosts, and restore-test rituals.