BorgBackup (Debian)

Aus MattWiki

Quelle: https://borgbackup.readthedocs.io/en/stable/

Installation

Für Debian 8.0 Jessie gibt es im Backports-Repository aktuelle Pakete:

# apt-get install borgbackup -t jessie-backports

Backuprepository initiieren

Zunächst muss ein Repository initiiert werden, z. B. auf der lokalen Maschine:

borg init --encryption=none|repokey|keyfile /PATH/TO/REPOSITORY/NAME

Initiierung eines Repository auf einer entfernten Maschine:

Standardmäßig wird das Repository mit Passwort verschlüsselt --encryption=repokey. Dabei wird das Keyfile im Repository gespeichert und mit einem Passwort gesichert.

Alternativ kann die Verschlüsselung deaktiviert werden mit --encryption=none oder es kann mit --encryption=keyfile so verschlüsselt werden, dass das Keyfile lokal in ~/.cache/borg/keys/ gespeichert wird und mit einem passwort gesichert wird.

Remote-Repositories

Können auf zwei Arten angelegt werden:

sshfs

oder mit Borg auf dem Remote-Repository installiert:

borg init ssh://server.domain.tld:port/PATH/TO/REPOSITORY/NAME
borg init ssh://user@server.domain.tld:port/PATH/TO/REPOSITORY/NAME

Backup erstellen

Beim erstellen eines Backups wird ein neues Archiv in einem Repository erstellt. Der Archivname und die zu archivierenden Daten müssen angegeben werden:

borg create -s -v --list /path/to/repo::my-files \
     ~/Documents                                 \
     ~/src                                       \
     --exclude '*.pyc'

Informationen über Backupinhalte

borg list REPOSITORY                           # List archives in REPOSITORY
borg list REPO::ARCHIVE                        # List contents of ARCHIVE in REPO
borg list ssh://user@server:port/PATHTOREPO    # List contents of remote REPOSITORY via SSH
borg info REPO::ARCHIVE                        # Show details for ARCHIVE such as time and size
borg info ssh://user@server:port/REPO::ARCH    # Show details for ARCHIVE such as time and size                      
                                               # from remote REPOSITORY accessed via SSH

Backup wiederherstellen

borg extract --info REPO::ARCHIVE              # extract ARCHIVE to current directory with debug level info / verbose (-v) 
borg extract --list REPO::ARCHIVE              # extract ARCHIVE to current directory with verbose list
borg extract --list -n REPO::ARCHIVE           # dry-run ARCHIVE to current directory with verbose list 
borg extract --list --dry-run REPO::ARCHIVE    # dry-run with verbose list 

Archiv mounten

Ein Archiv kann ins Dateisystem gemountet werden.

Verzeichnis erstellen und gesamtes Repository mounten:

mkdir ~/borgmount
borg mount REPO ~/borgmount

Alternativ kann auch ein einzelnes Archiv gemountet werden:

borg mount REPO::ARCHIVE

Unmounten:

borg umount ~/borgmount

Key export und import

Export auf Papier:

borg key export --paper /path/to/repo /export/to/path

Import von Papier:

borg key import --paper /path/to/repo /import/from/path

.