Borg backup

提供: ArchWiki
2023年2月7日 (火) 06:15時点におけるKgx (トーク | 投稿記録)による版 (→‎Documentation: 翻訳)
ナビゲーションに移動 検索に移動

関連記事

BorgBackup(略してBorg)は重複排除バックアッププログラムです。 オプションで、圧縮と認証済み暗号化をサポートします。

Borg の主な目標は、データをバックアップするための効率的かつ安全な方法を提供することです。使用されるデータ重複排除技術により、変更のみが保存されるため、Borg は毎日のバックアップに適しています。認証された暗号化技術により、完全に信頼されていないターゲットへのバックアップに適しています。

インストール

borg パッケージを インストール して下さい、 開発版は borg-gitAUR で利用できます。

追加機能については、次のパッケージをインストールします。

python-llfuse
アーカイブのマウント用
openssh
リモートホストへの接続用
borgmatic
ターミナルコマンドの代わりに YAML ファイルを介して Borg を制御する一連のラッパースクリプト
pika-backupAUR
Borg 用の libadwaita/GTK4 ベースの GUI
vortaAUR
Borg 用の Qt ベースの GUI

ドキュメント

公式 ドキュメント には -サンプルクイックスタートガイド ローカルドキュメントは borg(1)apropos borg にあります。

さらに、一般的に次のいずれかのコマンドを使用してガイダンスを見つけることができます。

$ borg help

または特定のコマンドの場合:

$ borg help command

Usage

The main concept behind Borg is de-duplication: rather than accumulating files as in traditional TAR archiving, de-duplication verifies the identity of files, regardless of their names, by hashing them so that they are only copied once. This means that even without compression, it takes up minimal space for repeated incremental backups.

File compression is optional and supports multiple algorithms (zstd is recommended) and intensities.

Archives created with Borg can be mounted as FUSE filesystems for browsing and restoring individual files.

Archives can be created locally, or on remote systems using SSHFS, NFS, Samba, or similar mounting solutions. Transfer over SSH is supported, but the remote host must have Borg available.

Creating repositories

Borg repositories can be encrypted or made tamper-evident. For more information on modes and options, consult the official documentation on setting up a repository.

To create a Borg repository without encryption or authentication:

$ borg init --encryption=none /path/to/repo

Creating archives

Individual archive instances can be created within the repository with the borg create command. Each archive must be given a unique name. Borg includes a list of placeholders to make adding strings such at dates, times, usernames, and hostnames easier.

To create an archive of the archivable-dir directory with the hostname of the source machine and the current date:

$ borg create /path/to/repo::{hostname}-{now:%Y-%m-%d} archivable-dir

Borg supports extensive inclusion and exclusion options. To exclude .py files from the archive:

$ borg create ... --exclude '*.pyc' /path/to/repo::archive-name

More information can be found on the borg create documentation page.

Pruning archives

The removal of old archives is not performed automatically, but can be performed manually with the borg prune command. The number of archives to keep must be specified, and can be limited by the time the archive was created.

To keep only the last 7 daily archives, the last four weekly archives, and the last three monthly archives:

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

To keep only the last 10 archives, regardless of when they were created:

$ borg prune --keep-last=10 /path/to/repo

To keep all archives from the past 30 days, regardless of how many archives that includes:

$ borg prune --keep-within=30d /path/to/repo
ノート: Pruning will delete the archives but will not actually free space in the repository. To free space, use the borg compact command on the repository.
警告: Pruning is performed on all archives in the repository unless restricted by the --prefix or --glob-archives flags.

More information can be found on the borg prune documentation page.

Restoring from an archive

To restore from an archive:

$ borg extract /path/to/repo::archive-name path/to/restore
ノート: Borg will extract the full path relative to the current working directory. This means that restoring the path /home/archuser/path/to/restore from an archive while in the archuser's home directory will result in the full restored path being /home/archuser/home/archuser/path/to/restore

.

Alternatively, a repository can be mounted for interactive restoration:

$ borg mount /path/to/repo::archive-name

Tips and tricks

Cache exclusion

Archives' size can be reduced by excluding cache directories. Directories that adhere to the Cache Directory Archiving Standard can be automatically excluded by appending --exclude-caches to the archive creation command:

$ borg create ... --exclude-caches /path/to/repo::archive-name

Listing affected files

Many operations in Borg support the --list flag to list affected files or archives. If paired with --dry-run, the user can verify the effects of a given command.

See also