Pulling a single file from a Borg backup without unpacking the whole archive is a common task for sysadmins who need quick recovery of a configuration file, a database dump, or a user document.
The following walkthrough shows how to do it safely, efficiently, and with a minimal security footprint.
Why pull a single file?
- Speed – Extracting an entire archive can take minutes or hours on large repositories.
- Disk space – You may not have room to unpack thousands of files.
- Security – Extracting only what you need reduces the attack surface; you avoid exposing the rest of the backup to the current filesystem.
- Automation – Scripts that restore a single file can run in CI/CD pipelines or as part of a systemd timer.
Borg basics recap
Borg is a deduplicating backup program that stores data in a repository.
Each backup is an archive that can contain one or more directories.
The repository can be local or remote (SSH, HTTP, or a network filesystem).
Borg supports strong encryption (repokey, passphrase, or keyfile) and can be configured to use a keyfile stored on the backup host.