Hier der kurze Praxistest 🙂
root@visionfive2:/etc# apt install restic Reading package lists... Done Building dependency tree... Done Reading state information... Done Suggested packages: libjs-sphinxdoc sphinx-rtd-theme-common The following NEW packages will be installed: restic 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 6,899 kB of archives. After this operation, 20.8 MB of additional disk space will be used. Get:1 http://ports.ubuntu.com lunar/universe riscv64 restic riscv64 0.14.0-1 [6,899 kB] Fetched 6,899 kB in 1s (5,589 kB/s) Selecting previously unselected package restic. (Reading database ... 34675 files and directories currently installed.) Preparing to unpack .../restic_0.14.0-1_riscv64.deb ... Unpacking restic (0.14.0-1) ... Setting up restic (0.14.0-1) ... Processing triggers for man-db (2.11.2-1) ... root@visionfive2:/etc# restic version restic 0.14.0 compiled with go1.19.2 on linux/riscv64 root@visionfive2:/etc# restic self-update writing restic to /usr/bin/restic find latest release of restic at GitHub latest version is 0.15.2 download SHA256SUMS download SHA256SUMS.asc GPG signature verification succeeded download restic_0.15.2_linux_riscv64.bz2 downloaded restic_0.15.2_linux_riscv64.bz2 saved 21954560 bytes in /usr/bin/restic successfully updated restic to version 0.15.2 root@visionfive2:/etc# restic version restic 0.15.2 compiled with go1.20.3 on linux/riscv64 root@visionfive2:/etc#Restic - Rootserver als Datenablage nutzen
-
Wir nehmen hier in diesem Beispiel an, wir nutzen irgendwo im Netz einen Server und wollen unser Homeverzeichnis sichern. Restic funktioniert, der Server ist eingerichtet.
Mit Restic können wir die Daten beruhigt auf den Server schieben, die Daten werden AES-256 verschlüsselt abgelegt.
Was brauchen wir?
- Datei /root/excludes.txt
- Datei /root/passwd
- Datei ~/.ssh/config
/root/excludes.txt
Die Datei excludes.txt beinhaltet eine Liste der Dateien, die wir nicht sichern wollen.
.cache Bilder Downloads Musik Videos
Je nach Vorlieben kann das dann entsprechend eingestellt werden. Die nächste Datei ist ~/.ssh/config
~/.ssh/config
Host <ip address> User <user name> Port <port>
Hintergrund für diese Datei. Man kann Restic keinen Port mit übergeben. Wenn man nun, was sinnvoll ist, den Standardport für SSH verlegt habt, dann benötigt man diese Datei damit Restic richtig funktioniert. Das könnt Ihr hier nachlesen.
/root/passwd
Hier kommt das Paswort rein, was wir dem Script mit übergeben. So mit taucht das Passwort auch nicht z.B. in htop auf!!
Passwd12345678
Wir starten mit der Erstellung.
Restic Init
root@frank-MS-7A34:~# restic -r sftp:<ip address>:/<user>/backup/home init enter password for new repository: enter password again: created restic repository fffffffffffffa at sftp:<ip address>:/<user>/backup/home Please note that knowledge of your password is required to access the repository. Losing your password means that your data is irrecoverably lost.
Erledigt. Die Einrichtung ist abgeschlossen.
Restic Backup
root@frank-MS-7A34:~# restic --password-file /root/passwd -r sftp:<ip address>:/root/backup/home backup --verbose /home/frank --exclude-file=excludes.txt open repository repository fffffffffff opened successfully, password is correct created new cache in /root/.cache/restic lock repository load index files start scan on [/home/frank] start backup on [/home/frank] scan finished in 3.888s: 52480 files, 9.811 GiB <gekürzt!>
Das oben ist nur der Anfang, danach sichert Restic die ganzen Daten auf dem Rootserver. Das Ganze als kleines Script.
Script
#!/bin/bash # Script um mit Restic Daten automatisiert zu sichern! #Was soll gesichert werden? backup_pfad=/home/frank #Programm Start restic --password-file /root/passwd -r sftp:<ip address>:/root/backup/home backup --verbose $backup_pfad --exclude-file=excludes.txt
Nix besonderes, aber funktioniert. Das Script dann mittels
crontab -e
als User root eintragen und fertig!
Für Anwender, die das nicht als User Root laufen lassen wollen, gibt es hier eine Erklärung wie man es macht. (Ganz unten)
-
Ok, das erste Backup dauert immer was länger In meinem Fall 5 Std. 16 Minuten.
Files: 33408 new, 0 changed, 0 unmodified Dirs: 1 new, 0 changed, 0 unmodified Data Blobs: 20849 new Tree Blobs: 2 new Added to the repo: 6.278 GiB processed 33408 files, 8.604 GiB in 5:16:03 snapshot 5beg1cb3 saved
Aber, das Schöne ist, das die Backups inkrementell angelegt werden. Das nächste geht schneller
open repository repository 3gg202a2 opened successfully, password is correct lock repository load index files using parent snapshot 5beg1cb3 start scan on [/home/frank] start backup on [/home/frank] scan finished in 3.791s: 33788 files, 8.611 GiB Files: 496 new, 74 changed, 33218 unmodified Dirs: 0 new, 1 changed, 0 unmodified Data Blobs: 292 new Tree Blobs: 2 new Added to the repo: 43.661 MiB processed 33788 files, 8.611 GiB in 2:15 snapshot fag41bf7 saved
Eine tägliche Sicherung sollte dann wohl reichen.
-
-
-
-
-
-
-
SSH Login ohne Passwort
Angeheftet Linux -
Restic - Ein Backupkonzept
Angeheftet Restic