$linuxjunkies
>

borg(1)

Borg Backup is a deduplicating backup program that creates space-efficient, encrypted backups with a focus on security and performance.

UbuntuDebianFedoraArch

Synopsis

borg [GLOBAL_OPTIONS] COMMAND [COMMAND_OPTIONS] [ARGUMENTS]

Description

Borg Backup deduplicates file content across multiple backups, storing only the data that has changed. It uses strong encryption by default and is designed for both local and remote backups over SSH. Each backup is called an "archive" and multiple archives are stored in a "repository."

Borg is ideal for automated backups and handles large datasets efficiently by detecting and storing only new or modified content. It supports incremental backups, checksumming, and recovery from incomplete or corrupted backups.

Common options

FlagWhat it does
-v, --verboseDisplay verbose progress information
--progressShow progress information during long operations
--listList the archives in a repository or files in an archive
-e, --excludeExclude files matching pattern (can be used multiple times)
--exclude-fromRead exclusion patterns from file
-s, --statsDisplay backup statistics (stored size, deduplicated size, original size)
--compressionSet compression algorithm (lz4, zstd, zlib, or none); e.g., lz4 or zstd,6
--checkpoint-intervalCreate intermediate checkpoints every N seconds (default: 300)
--one-file-systemDo not cross filesystem boundaries
--keep-daily, --keep-weeklyKeep N daily/weekly backups when pruning (used with 'prune' command)

Examples

Initialize a new encrypted repository at /mnt/backup/myrepo with a password-protected key

borg init -e repokey /mnt/backup/myrepo

Create a backup archive named with current timestamp, backing up /home/user/documents with progress display

borg create --progress --stats /mnt/backup/myrepo::{now} /home/user/documents

List all archives stored in the repository

borg list /mnt/backup/myrepo

Extract a specific archive to restore files

borg extract --progress /mnt/backup/myrepo::backup-2024-01-15 /home/user/documents

Delete old backups according to retention policy (keep 7 daily, 4 weekly, 12 monthly)

borg prune --keep-daily=7 --keep-weekly=4 --keep-monthly=12 /mnt/backup/myrepo

Create backup while excluding patterns read from a file

borg create --exclude-from /etc/borg-exclude.txt /mnt/backup/myrepo::{now} /home

Backup with multiple exclusions and zstd compression at level 6

borg create -e '*.tmp' -e '.cache' --compression zstd,6 /mnt/backup/myrepo::{now} /home/user

Create a backup on a remote server over SSH (remote repository)

borg create --progress [email protected]:backup-repo::{now} /home/user

Related commands