Skip to content

Restic - Passwortübergabe

Restic
  • 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 😉

  • Restic feiert 10. Geburtstag

    Restic
    1
    0 Stimmen
    1 Beiträge
    55 Aufrufe
    Niemand hat geantwortet
  • Rest-Server v0.12.0 released

    Restic
    1
    0 Stimmen
    1 Beiträge
    65 Aufrufe
    Niemand hat geantwortet
  • Restic - riscv64

    Restic
    4
    0 Stimmen
    4 Beiträge
    130 Aufrufe
    FrankMF

    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 - Migrate

    Restic
    1
    0 Stimmen
    1 Beiträge
    157 Aufrufe
    Niemand hat geantwortet
  • 0 Stimmen
    5 Beiträge
    724 Aufrufe
    FrankMF

    @berthold Hallo Berthold. Ich bin eigentlich immer noch nicht mit meinem Code zufrieden. Ist man das jemals? Da ich auch noch ein kleines Problem habe, würde ich da ungerne jemanden reinschauen lassen. Der Code ist stellenweise in deutsch kommentiert, stellenweise in englisch. Kennt man ja, man will es irgendwann mal ordentlich machen und dann kommt das nächste Problem auf einen zu.

    Hast Du Python3 Vorkenntnisse? Wenn Du "brennend" dran interessiert bist, könnte ich Dir evt. Zugang zu meinem Gitlab-Projekt geben.

    Wenn Du interessiert bist und ich dich nicht los werde :), dann schreib mir eine PN.

  • Restic - Mounten der Sicherung

    Restic
    2
    0 Stimmen
    2 Beiträge
    295 Aufrufe
    FrankMF

    Bedingt durch einen Hardwareumbau und einer folgenden Neuinstallation, musste ich das Gestern mal live testen. Das klappt hervorragend 🙂 Die Sicherung einbinden und dann gemütlich alles wieder zurück kopieren, was man braucht. Perfekt!

  • Restic - Backblaze B2 Cloud Storage

    Restic
    1
    0 Stimmen
    1 Beiträge
    365 Aufrufe
    Niemand hat geantwortet
  • Restic - Update

    Restic
    1
    0 Stimmen
    1 Beiträge
    393 Aufrufe
    Niemand hat geantwortet