linux-nerds.org

    linux-nerds.org

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular

    Restic - Passwortübergabe

    Restic
    restic
    1
    1
    39
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • FrankM
      FrankM last edited by FrankM

      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 😉

      1. RockPro64 v2.1 / PCIe SATA 5 Ports / Boot direct from port 5 SSD / 2 * 3,5 Zoll 4TB HDD (raid1) / 2 * 2,5 Zoll 2 TB (raid 1) using as NAS / Kernel Linux NASrp64 5.6.0-1137-ayufan-ge57f05e7bf8f

      2. RockPro64 v2.1 for testing ;)

      3. Quartz64 Model A

      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      • FrankM

        Restic v0.13.0 released
        Restic • restic restic-ui • • FrankM

        1
        0
        Votes
        1
        Posts
        25
        Views

        No one has replied

      • FrankM

        Rest-Server v0.11.0
        Restic • rest-server restic • • FrankM

        1
        0
        Votes
        1
        Posts
        31
        Views

        No one has replied

      • FrankM

        checkmk - Rest-Server überwachen
        checkmk • checkmk linux restic • • FrankM

        1
        0
        Votes
        1
        Posts
        151
        Views

        No one has replied

      • FrankM

        Restic v0.12.0 released
        Restic • linux restic • • FrankM

        1
        0
        Votes
        1
        Posts
        129
        Views

        No one has replied

      • FrankM

        Restic v0.11.0 released
        Restic • restic • • FrankM

        1
        0
        Votes
        1
        Posts
        125
        Views

        No one has replied

      • FrankM

        Restic - Backblaze B2 Cloud Storage
        Restic • backblaze linux restic • • FrankM

        1
        0
        Votes
        1
        Posts
        243
        Views

        No one has replied

      • FrankM

        Restic - Update
        Restic • linux restic • • FrankM

        1
        0
        Votes
        1
        Posts
        301
        Views

        No one has replied

      • FrankM

        Restic - Ein Backupkonzept - Automatisieren!
        Restic • linux restic • • FrankM

        1
        0
        Votes
        1
        Posts
        945
        Views

        No one has replied

      Powered by NodeBB | Contributors
      © 2022 frank-mankel.de