LinuxCommandLibrary

borg

Deduplicating, authenticated, and compressed backup archiving

TLDR

Initialize a (local) repository

$ borg init [path/to/repo_directory]
copy

Backup a directory into the repository, creating an archive called "Monday"
$ borg create --progress [path/to/repo_directory]::[Monday] [path/to/source_directory]
copy

List all archives in a repository
$ borg list [path/to/repo_directory]
copy

Extract a specific directory from the "Monday" archive in a remote repository, excluding all *.ext files
$ borg extract [user]@[host]:[path/to/repo_directory]::[Monday] [path/to/target_directory] --exclude '[*.ext]'
copy

Prune a repository by deleting all archives older than 7 days, listing changes
$ borg prune --keep-within [7d] --list [path/to/repo_directory]
copy

Mount a repository as a FUSE filesystem
$ borg mount [path/to/repo_directory]::[Monday] [path/to/mountpoint]
copy

Display help on creating archives
$ borg create --help
copy

SYNOPSIS

borg [COMMON_OPTIONS] <COMMAND> [SUB_OPTIONS] [PATHS...]

PARAMETERS

--repo PATH, -r PATH
    Path to repository (can be remote: user@host:path)

-C COMPRESSION, --compression COMPRESSION
    Compression algorithm (none, lz4, zstd, zlib, lzma)

--passphrase
    Read passphrase from stdin (interactive)

--passphrase-fd FD
    Read passphrase from given file descriptor

--info
    Enable info-level logging

-v, --verbose
    Increase verbosity level (repeatable)

--progress
    Show progress bars

--stats
    Print statistics for this operation

--dry-run, -n
    Do not change anything, just show what would be done

--lock-wait N
    Wait up to N seconds for acquiring a repository lock

--checkpoint-interval SECONDS
    Write checkpoint every N seconds during backup

--debug
    Enable debug logging

DESCRIPTION

Borg (BorgBackup) is a powerful, efficient deduplicating backup tool for Unix-like systems including Linux. It creates archives in a central repository using content-defined chunking, storing only unique data blocks to minimize storage use. This enables space-efficient incremental backups, as new archives reference existing chunks.

Key features:
• Deduplication: Identical data stored once across archives.
• Compression: Supports lz4, zstd, zlib, lzma.
• Encryption: Client-side AES-CTR-256 + HMAC-SHA256 (authenticated).
• Incremental: Efficient deltas from prior archives.
• Mountable: FUSE to browse archives as filesystems.
• Pruning: Automated retention with borg prune.

Workflow: Initialize repo with borg init, create backups with borg create, verify with borg check, restore via borg extract or mount. Repos work locally or remotely (SSH). Written in Python 3, no root needed. Ideal for servers, VMs, home dirs. Handles billions of chunks scalably.

CAVEATS

Requires borg init before use. Client-side encryption means secure passphrase storage is critical (no recovery). Remote access needs SSH keys. Cache dirs (~/.cache/borg) use disk/SSD for speed on large repos. Not for real-time replication; append-only repos.

MAIN SUBCOMMANDS

init: Initialize repository.
create: Create archive from paths.
list: List archives or contents.
extract: Extract archive contents.
check: Verify repository integrity.
prune: Delete old archives by rules.
mount: Mount archive as FUSE filesystem.
info: Show archive details.

BASIC EXAMPLES

borg init --encryption=repokey ssh://user@backupserver/./repo
borg create repo::snapshot-{now:%Y-%m-%d} /home /etc
borg prune --keep-daily=7 --keep-weekly=4 repo

HISTORY

Forked from Attic in 2015 by Thomas Waldmann (<tmz>). Attic (2010-2015) discontinued; Borg added content chunker, encryption, better UX, pruning. Renamed BorgBackup 1.0 (2016). Active development: v1.2+ supports Apple Silicon, zstd. Community-maintained, 10k+ GitHub stars.

SEE ALSO

rsync(1), tar(1), restic(1), rdiff-backup(1), duplicity(1)

Copied to clipboard