Geschrieben von Frank Mankel
Kategorie: Linux

Wie alles anfing ;)

Da ich immer furchtbar neugierig bin, musste ich mir das ansehen. Außerdem war ich schon lange auf der Suche nach einem Backuptool das die Daten verschlüsselt ablegt. Aber, Nico lässt immer die Erklärungen weg, so das ich da dann wieder ran muss ;) Fangen wir an.

 

Installation:

Restic ist mit der Programmiersprache Go geschrieben worden, so das Restic das Go Paket verlangt. Das muss also installiert werden.

sudo apt-get install golang-go

Unter meinem LinuxMint Cinnamon bekam ich leider eine zu alte Version installiert (1.7). Restic wollte aber eine aktuellere haben (1.8) :( Was machen?

Lösung: https://github.com/golang/go/wiki/Ubuntu

sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt-get update
sudo apt-get install golang-go
 
Ergebnis:
 
go version
go version go1.8 linux/amd64
 
Nun installieren wir Restic.
 
cd tmp
git clone https://github.com/restic/restic
cd restic
go run build.go
 
Danach ist das ausführbare Programm Restic erzeugt worden. Wenn man es dauerhaft benutzen will kopiert man es nach /usr/bin
 
sudo cp restic /usr/bin
 
Wenn Restic in /usr/bin liegt reicht ein
 
restic
 
um das Programm zu starten.
  
Ausgabe:

restic version
restic 0.5.0 (v0.5.0-49-ga725e06)
compiled with go1.8 on linux/amd64
 
Fertig!
 

Repository anlegen! 

 
restic -r /tmp/repo init
 
-r = Repository
/tmp/repo = Ort
init = initialisieren
 
Ausgabe:
 
restic -r /tmp/repo init
enter password for new backend: 
enter password again: 
created restic backend 1db770b830 at /tmp/repo
 
Please note that knowledge of your password is required to access
the repository. Losing your password means that your data is
irrecoverably lost.
 

Backup erzeugen!

restic -r /tmp/repo backup /home/frank/Bilder
 
Ausgabe:
 
restic -r /tmp/repo backup /home/frank/Bilder
enter password for repository: 
scan [/home/frank/Bilder]
scanned 38 directories, 410 files in 0:00
[0:14] 100.00%  101.932 MiB/s  1.412 GiB / 1.412 GiB  448 / 448 items  0 er... ETA 0:00 
duration: 0:14, 101.45MiB/s
snapshot 06c3e12b saved
 
Repository Inhalt anzeigen

restic -r /tmp/repo snapshots
enter password for repository:
ID Date Host Tags Directory
----------------------------------------------------------------------
06c3e12b 2017-04-07 21:54:03 frank-MS-7850 /home/frank/Bilder
644a30bc 2017-04-07 21:55:52 frank-MS-7850 /home/frank/Bilder

------------------------------------

Ein Repo mal mounten

sudo restic -r /tmp/repo mount /mnt/temp
[sudo] Passwort für frank:
enter password for repository:
Now serving the repository at /mnt/temp
Don't forget to umount after quitting!

Wichtig: Man muss die entsprechenden Rechte für das Verzeichnis haben, ich hab es hier mal als sudo gemacht.

Das Fenster bleibt aktiv. Also ein anderes öffnen um sich dann im Repo umzusehen.

Und zum Schluß:


umount /mnt/temp

 

Snapshot restoren

restic -r /tmp/repo restore -t /tmp/restore 644a30bc

Ausgabe:


restic -r /tmp/repo restore -t /tmp/restore 644a30bc
enter password for repository:
restoring to /tmp/restore

 

Geschwindigkeitsbeispiele:

Beispiel 1: Ein Backup auf meinem Haupt-PC mit schneller SSD. Bilder-Ordner nach /tmp zum Testen.

restic -r /tmp/repo backup /home/frank/Bilder
enter password for repository: 
scan [/home/frank/Bilder]
scanned 38 directories, 410 files in 0:00
[0:14] 100.00%  101.932 MiB/s  1.412 GiB / 1.412 GiB  448 / 448 items  0 er... ETA 0:00 
duration: 0:14, 101.45MiB/s
snapshot 06c3e12b saved
 
Ergebnis: 101.45 MiB/s
 
Beispiel 2: Backup von meinem NAS (mechanische HDD's) auf eine interne HDD auf meinem Haupt-PC.
 
restic -r /media/privat/Test backup /media/NAS/Dokumente
enter password for repository:
scan [/media/NAS/Dokumente]
scanned 40777 directories, 229185 files in 2:13
[14:17] 100.00% 50.902 MiB/s 42.604 GiB / 42.604 GiB 269962 / 269962 items 0 errors ETA 0:00
duration: 14:17, 50.86MiB/s
snapshot c10894df saved
 
Ergebnis: 50.86MiB/s
 
Macht man das Backup erneut (keine Änderungen), erhält man folgendes.
 
/restic -r /media/privat/Test backup /media/NAS/Dokumente
enter password for repository:
using parent snapshot c10894df
scan [/media/NAS/Dokumente]
scanned 40777 directories, 229185 files in 1:30
[2:41] 100.00% 269.293 MiB/s 42.604 GiB / 42.604 GiB 269962 / 269962 items 0 errors ETA 0:01
duration: 2:41, 269.77MiB/s
snapshot 6776aa97 saved
 
Ergebnis: 269.77MiB/s
 
Da nichts zu schreiben ist, geht das deutlich schneller.
 

Scripte:

Für Scripte kann man noch folgende Variablen setzen:

export RESTIC_REPOSITORY =/tmp/repo RESTIC_PASSWORD=foo

 
Beispiel Script:
 
#!/bin/bash
# Script um meine Dokumente vom NAS regelmäßig zu sichern

# Repo definieren und PW hinterlegen
export RESTIC_REPOSITORY=/media/privat/Restic/Backup
export RESTIC_PASSWORD=12345678

#Was soll gesichert werden?
backup_pfad=/media/NAS/Dokumente

#Programm Start
restic -r $RESTIC_REPOSITORY backup $backup_pfad


 
Fazit:
Klasse Tool und der Programmierer hat in seinem Video nicht zu viel versprochen. Schnell, sicher, einfach, was will man mehr. Dann fang ich mal an, ein wenig umzubauen und meine rsync's in die Tonne zu kloppen :) Vielen Dank @Nico für den Tipp und @Alexander für das tolle Tool. Diese kurze Anleitung basiert auf dem Talk "restic - Backups mal richtig"
von Alexander vom 2.2.2016. Den Link und weitere interessante Links findet ihr etwas tiefer.

 

Update:

Ein Hinweis vom Alexander:

 

Links:

Restic

Restic github

golang

Installation unter Ubuntu

Installation unter Debian

Video über Restic