What is Borg?
BorgBackup (Borg) is a deduplicating backup program that provides efficient, compressed, and encrypted backups. It only stores changed data blocks, making incremental backups extremely fast and space-efficient.
Installation
sudo apt install -y borgbackupInitialize a Repository
# Local repository
borg init --encryption=repokey /backup/borg-repo
# Remote repository
borg init --encryption=repokey ssh://backupuser@remote-server/backups/borg-repoCreating a Backup
borg create --stats --progress \
/backup/borg-repo::backup-{now:%Y-%m-%d} \
/var/www \
/etc \
/home \
--exclude "*.log" \
--exclude "/home/*/.cache"Restoring Files
# List available backups
borg list /backup/borg-repo
# Restore specific backup
cd /tmp/restore
borg extract /backup/borg-repo::backup-2026-02-25
# Restore a single file
borg extract /backup/borg-repo::backup-2026-02-25 var/www/html/index.phpAutomated Pruning
borg prune --keep-daily=7 --keep-weekly=4 --keep-monthly=6 /backup/borg-repoThis keeps 7 daily, 4 weekly, and 6 monthly backups — automatically removing older archives to save space.