Skip to content

Restic - Passwortübergabe

Restic
1 1 232
  • Es gibt in Restic mehrere Möglichkeiten, das Repository Passwort zu übergeben. Der normale Weg.

    restic -r /tmp/repo backup /home/frank/Bilder
    enter password for repository: 
    password is correct
    

    Das Backup wird gestartet und man wird nach dem Repository Passwort gefragt. Für eine evt. Automatisierung ist das aber nicht so toll. Da Entwickler aber faul sind 🙂 , hat man sich auch ein paar andere Dinge einfallen lassen.

    restic -r /home/frank/b5 /home/frank/Bilder --password-file restic_pw.txt 
    

    oder

    restic -r /home/frank/b5 backup /home/frank/Bilder --password-command SCRIPT
    

    Übergabe mit --password-file

    Das Passwort liegt dazu in einem File und wird mittels

    --password-file

    übergeben. Das Ergebnis sieht dann so aus.

    frank@frank-MS-7C37:~$ restic -r /home/frank/b5 backup /home/frank/Bilder --password-file  pw.txt
    repository 87835251 opened successfully, password is correct
    found 15 old cache directories in /home/frank/.cache/restic, run `restic cache --cleanup` to remove them
    using parent snapshot 3171ef48
    
    Files:           0 new,     0 changed,   160 unmodified
    Dirs:            0 new,     2 changed,    14 unmodified
    Added to the repo: 747 B
    
    processed 160 files, 173.780 MiB in 0:00
    snapshot 0f2b19e6 saved
    

    Übergabe mit -password-command

    Test-Script test.sh

        #!/bin/sh
        echo "123456"
    

    Das wird dann mittels --password-command übergeben.

    restic -r /home/frank/b5 backup /home/frank/Bilder --password-command  /home/frank/test.sh
    repository 87835251 opened successfully, password is correct
    found 15 old cache directories in /home/frank/.cache/restic, run `restic cache --cleanup` to remove    them
    using parent snapshot 1b4adc5a
    
    Files:           0 new,     0 changed,   160 unmodified
    Dirs:            0 new,     2 changed,    14 unmodified
    Added to the repo: 747 B
    
    processed 160 files, 173.780 MiB in 0:00
    snapshot 23677375 saved
    

    Übergabe mit verschlüsseltem Passwort

    Das obere Test Script habe ich mal verschlüsselt

    gpg -c test.sh
    

    Das Ergebnisfile heißt dann test.sh.gpg . Danach kann man dann das Test Script umschreiben.

    #!/bin/sh
    cd /tmp
    gpg -d /home/frank/test.sh.gpg > schluessel.sh
    chmod +x schluessel.sh
    ./schluessel.sh
    rm schluessel.sh
    

    Und wenn man jetzt das Restic Backup mit

    restic -r /home/frank/b5 backup /home/frank/Bilder --password-command  /home/frank/test.sh
    

    aufruft, wird das PW aus dem verschlüsselten File benutzt.

    frank@frank-MS-7C37:~$ restic -r /home/frank/b5 backup /home/frank/Bilder --password-command  /home/frank/test.sh
    gpg: AES256 verschlüsselte Daten
    gpg: Verschlüsselt mit einer Passphrase
    repository 87835251 opened successfully, password is correct
    found 15 old cache directories in /home/frank/.cache/restic, run `restic cache --cleanup` to remove them
    using parent snapshot d6226569
    
    Files:           0 new,     0 changed,   160 unmodified
    Dirs:            0 new,     2 changed,    14 unmodified
    Added to the repo: 747 B
    
    processed 160 files, 173.780 MiB in 0:00
    snapshot 86ca3ca9 saved
    

    Sollte der GPG Schlüsselbund nicht entsperrt sein, wird man nach seinem Passwort dafür gefragt.

    Übergabe mittels stdin in Python Code

    In meinem Restic UI habe ich das wie folgt gelöst.

    result = subprocess.run(['restic',
                                                    '-r',
                                                     backup_data[row].repository,
                                                     'backup',
                                                     backup_data[row].source],
                                                    input=pass_word.pw[0],
                                                    check=False,
                                                    capture_output=True,
                                                    text=True)
    

    Fazit

    Eine Menge Möglichkeiten aus denen man anhand der Schwere seiner Datenparanoia auswählen kann 😉

  • Vorstellung Restic UI Flask

    Restic UI Flask restic restic-ui flask python
    1
    6
    0 Stimmen
    1 Beiträge
    286 Aufrufe
    Niemand hat geantwortet
  • Restic v0.16.2

    Linux restic linux
    1
    0 Stimmen
    1 Beiträge
    154 Aufrufe
    Niemand hat geantwortet
  • Rest-Server Version 0.12.1 released

    Linux rest-server restic linux
    1
    0 Stimmen
    1 Beiträge
    130 Aufrufe
    Niemand hat geantwortet
  • checkmk - Rest-Server überwachen

    Verschoben checkmk checkmk linux restic
    1
    3
    0 Stimmen
    1 Beiträge
    569 Aufrufe
    Niemand hat geantwortet
  • Restic v0.10.0 released

    Restic restic
    2
    0 Stimmen
    2 Beiträge
    260 Aufrufe
    FrankMF
    Gerade erst gelesen, man kann folgendes machen, damit es sich aktualisiert. root@debian:~# restic self-update writing restic to /usr/bin/restic find latest release of restic at GitHub latest version is 0.10.0 download SHA256SUMS download SHA256SUMS.asc GPG signature verification succeeded download restic_0.10.0_linux_amd64.bz2 downloaded restic_0.10.0_linux_amd64.bz2 saved 18378752 bytes in /usr/bin/restic successfully updated restic to version 0.10.0 root@debian:~# restic version restic 0.10.0 compiled with go1.15.2 on linux/amd64 Klasse!
  • Rest-Server

    Verschoben Restic rest-server linux restic
    8
    0 Stimmen
    8 Beiträge
    746 Aufrufe
    FrankMF
    Dann mal eben ausprobiert. Auf meinem Server war die Version 0.9.7 selber, mit go, gebaut. Dann mache ich das auch mit der v0.10.0 so. Aber bevor ich anfange, wird die v0.9.7 gesichert. mv /usr/local/bin/rest-server /usr/local/bin/rest-server_0_9_7 So erspare ich mir im Problemfall das selber bauen. Ok, dann die neue Version bauen. git clone https://github.com/restic/rest-server.git cd rest-server go run build.go Danach befindet sich im Verzeichnis die Binärdatei rest-server Die kopieren wir jetzt cp rest-server /usr/local/bin Danach kurzer Test # rest-server --version rest-server 0.10.0 (v0.10.0-6-g037fe06) compiled with go1.11.6 on linux/amd64 Gut Version passt Dann ein Backup gestartet. Das sichert einen Teil meines Home-Verzeichnis Files: 153 new, 100 changed, 177857 unmodified Dirs: 0 new, 1 changed, 0 unmodified Added to the repo: 81.881 MiB processed 178110 files, 80.571 GiB in 0:28 snapshot 607e0027 saved Applying Policy: keep the last 3 snapshots, 3 monthly snapshots keep 5 snapshots: ID Time Host Tags Reasons Paths --------------------------------------------------------------------------------------- fa97890e 2020-07-25 21:02:05 frank-XXX monthly snapshot /home/frank 5b073bbb 2020-08-30 10:17:27 frank-XXX monthly snapshot /home/frank f7cf37ef 2020-09-06 15:13:03 frank-XXX last snapshot /home/frank 0157462c 2020-09-13 13:32:12 frank-XXX last snapshot /home/frank 607e0027 2020-09-14 08:09:34 frank-XXX last snapshot /home/frank monthly snapshot --------------------------------------------------------------------------------------- 5 snapshots remove 1 snapshots: ID Time Host Tags Paths --------------------------------------------------------------------- 3010b7cc 2020-09-06 11:39:27 frank-XXX /home/frank --------------------------------------------------------------------- 1 snapshots 1 snapshots have been removed, running prune counting files in repo building new index for repo [1:34] 100.00% 17351 / 17351 packs So weit funktioniert das genau wie vorher. Im Changelog stand ja was von Subfoldern. Das betrifft mich nicht, weil ich für jeden User genau ein Verzeichnis habe. So mit alles Gut Dann warte ich mal morgen ab, ob die täglichen Backups der Server rund laufen.
  • Restic - Backblaze B2 Cloud Storage

    Restic backblaze linux restic
    1
    2
    0 Stimmen
    1 Beiträge
    415 Aufrufe
    Niemand hat geantwortet
  • Restic - Rootserver als Datenablage nutzen

    Restic linux restic
    2
    0 Stimmen
    2 Beiträge
    798 Aufrufe
    FrankMF
    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.