BorgBackup

From Gentoo Wiki
Jump to:navigation Jump to:search
This article is a stub. Please help out by expanding it - how to get started.

BorgBackup (short: Borg) is a deduplicating backup program. Optionally, it supports compression and authenticated encryption.

The main goal of Borg is to provide an efficient and secure way to back up data. The data deduplication technique used makes Borg suitable for daily backups since only changes are stored. The authenticated encryption technique makes it suitable for backups to targets not fully trusted.

Installation

USE flags

USE flags for app-backup/borgbackup Deduplicating backup program with compression and authenticated encryption

debug Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces
test Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)
Data provided by the Gentoo Package Database · Last update: 2026年07月29日 10:54 More information about USE flags

Emerge

root #emerge --ask app-backup/borgbackup

Compatibility

There is a planned compatibility break in the development, not-yet-released 2.0 version. See the "Breaking compatibility" section of the preliminary release notes, as well as the general note in its documentation.

In the past, there have also been compatibility issues with old clients and new repositories, as well as when mixing different client versions because of security fixes.

Usage

Initializing a new repository

Before backups can be made, a repository must be initialized

user $borg init --encryption=repokey /path/to/repo

Backing up directories

user $borg create /path/to/repo::ArchiveName ~/src ~/Documents

The archive name may include placeholders which will expanded by borg, e.g. '{hostname}-{now}' would become something like 'panther-2024年08月31日T19:00:00'

Statistics can be output with the --stats argument.

user $borg create --stats /path/to/repo::ArchiveName ~/src ~/Documents
-----------------------------------------------------------------------------
Archive name: ArchiveName
Archive fingerprint: bd31004d58f51ea06ff735d2e5ac49376901b21d58035f8fb05dbf866566e3c2
Time (start): Tue, 2016年02月16日 18:15:11
Time (end): Tue, 2016年02月16日 18:15:11
Duration: 0.19 seconds
Number of files: 127
------------------------------------------------------------------------------
 Original size Compressed size Deduplicated size
This archive: 4.16 MB 4.17 MB 26.78 kB
All archives: 8.33 MB 8.34 MB 4.19 MB
 Unique chunks Total chunks
Chunk index: 132 261
------------------------------------------------------------------------------

Listing archives in a repository

user $borg list /path/to/repo
First Mon, 2016年02月15日 19:14:44
Second Tue, 2016年02月16日 19:15:11

Listing contents of an archive

user $borg list /path/to/repo::ArchiveName
drwxr-xr-x user group 0 Mon, 2016年02月15日 18:22:30 home/user/Documents
-rw-r--r-- user group 7961 Mon, 2016年02月15日 18:22:30 home/user/Documents/Important.doc
...

Restoring an archive

user $borg extract /path/to/repo::ArchiveName

Deleting an archive

user $borg delete /path/to/repo::ArchiveName

Pruning a repository

Pruning a repository allows borg to delete archives that do not need to be retained. This is useful for managing automated backups.

user $borg prune --keep-daily=7 --keep-weekly=4 --keep-monthly=6 /path/to/repo

Afterwards, use borg compact to free up repository disk space

Compacting a repository

Compacting a repository allows borg to recover disk space by compacting segment files

user $borg compact /path/to/repo

Mounting a repository

Mounting a repository uses FUSE to make the archives available as directories at the mount point, which is useful for browsing or restoring files and directories.

user $borg mount /path/to/repo /mount/point
user $ls -l /mount/point
drwxr-xr-x 1 root root 0 2024年03月31日 19:00 hostname-2024年03月31日T19:00:00
drwxr-xr-x 1 root root 0 2024年04月30日 19:00 hostname-2024年04月30日T19:00:01
...

It is also possible to mount a single archive

user $borg mount /path/to/repo::ArchiveName /mount/point

To unmount afterwards:

user $borg umount /mount/point

See also

  • restic — a Go-based backup tool built simplicity, scalability, and verifiability in mind.
  • dd — a utility used to copy raw data from a source into sink, where source and sink can be a block device, file, or piped input/output.
  • rsnapshot — an automated backup tool based on the rsync protocol and written in Perl.