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 Votes
    1 Posts
    49 Views
    No one has replied
  • 0 Votes
    1 Posts
    73 Views
    No one has replied
  • Restic - Migrate

    Restic
    1
    0 Votes
    1 Posts
    155 Views
    No one has replied
  • Restic v0.12.1 released

    Restic
    1
    0 Votes
    1 Posts
    153 Views
    No one has replied
  • Restic UI - kurzes Video

    Linux
    1
    0 Votes
    1 Posts
    166 Views
    No one has replied
  • Restic - Mounten der Sicherung

    Restic
    2
    0 Votes
    2 Posts
    291 Views
    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!

  • 0 Votes
    2 Posts
    790 Views
    FrankMF

    So, dann mal das Ganze testen wenn man seinen Haupt-PC neu installiert hat und ein paar Daten braucht.

    0_1534692578537_IMG_20180819_090116_ergebnis.jpg

    Also, mal Restic installiert.

    sudo apt-get install restic

    Nach erfolgter Installation ein Test

    frank@frank-MS-7A34:~/restic$ restic version restic 0.8.3 compiled with go1.10 on linux/amd64

    Geht so weit.

    Snapshots auflisten. restic -r sftp:rock64@IP:/home/rock64/backup snapshots

    Sieht dann so aus.

    frank@frank-MS-7A34:~$ sudo restic -r sftp:rock64@192.168.3.207:/home/rock64/backup snapshots [sudo] Passwort für frank: rock64@192.168.3.207's password: enter password for repository: password is correct ID Date Host Tags Directory ---------------------------------------------------------------------- 7e2eddcb 2018-08-18 10:10:40 frank-MS-7A34 /home/frank/Bilder 073b7cb4 2018-08-18 14:21:17 frank-MS-7A34 /home/frank 6bc9b21b 2018-08-18 16:11:19 frank-MS-7A34 /home/frank ---------------------------------------------------------------------- 3 snapshots Snapshot wiederherstellen sudo restic -r sftp:rock64@IP:/home/rock64/backup restore latest --target /tmp/backup

    Hiermit stellen wir das Backup im temporären Ordner /tmp/backup wieder her. Hat ewig gedauert, aber ging !?!?!?

  • Restic - Ein Backupkonzept

    Pinned Restic
    1
    0 Votes
    1 Posts
    1k Views
    No one has replied