Skip to content

Restic UI - Documentation

Restic UI
  • About

    My second Python3 PyQT5 project

    The project is a UI for the Linux tool restic

    Restic_UI_main_screen.png

    This project is quite far from perfect, but it helped me a lot to understand the world of Python3, VSCodium and gitlab a little bit.

    If it helps someone along the way as well, I'm glad. For questions and suggestions you can write me in my forum

    And now have fun with one of the best backup tools!

    Dependencies

    • restic
    • python3
    • python3-venv
    • pyqt5
    • requests

    Functions Restic-UI

    Restic functions that are included in the UI

    • init
    • backup
    • mount
    • restore
    • snapshots
    • ls
    • check
    • unlock
    • stats
    • prune
    • version

    Installation

    Install restic if not installed

    apt install restic
    restic self-update
    

    Clone Repository

    git clone https://gitlab.com/Bullet64/restic-ui-public.git
    

    Create env

    cd /home/USER/restic-ui-public
    python3 -m venv venv
    source venv/bin/activate
    

    Install dependencies

    pip install PyQt5
    pip install requests
    

    Usage

    python3 restic_ui.py
    

    Known problems

    I am not really satisfied with the programming of the Add Backup, Edit Backup and Settings windows yet. I still have to optimize that.

    The password of a backup is currently stored in plain text! The password field is optional!

    Release is planned for the coming weekend

  • Restic - 0.15.0 released

    Restic
    1
    0 Stimmen
    1 Beiträge
    50 Aufrufe
    Niemand hat geantwortet
  • Restic UI - Vorstellung Part 2

    Restic UI
    1
    0 Stimmen
    1 Beiträge
    122 Aufrufe
    Niemand hat geantwortet
  • 0 Stimmen
    3 Beiträge
    165 Aufrufe
    FrankMF

    Hallo @berthold, du bist mein einziger Star 🙂 Ok, darum geht es mir ja nicht, wie Du weißt mache ich das hauptsächlich für mich und meine Backups klappen damit sehr gut. Ist also produktiv einsetzbar.

    Wie Du gemerkt hast, gibt es Zeiten da mache ich ganz viel und dann wieder Zeiten da passiert nix. Das ist bei mir normal, ich muss da "Bock" drauf haben. Habe ich viel Stress auf der Arbeit, passiert Abends eher sehr wenig..

    Ich hoffe das ich mittlerweile alle Fehler gefunden habe, die Grundfunktionen sind alle funktional. Mittlerweile kann man die JSON Datei mit den Daten der Backups auf Wunsch auch verschlüsseln 🙂

    Ich habe noch eine ganze Reihe an Notizen, was ich gerne noch machen möchte. Wichtig ist mir aber im Moment, das ich alle Fehler finde und das so wie es jetzt ist, einwandfrei läuft.

    Darum, wenn es jemand nutzt, bitte gebt Feedback. Egal ob positiv oder negativ. Ich freue mich persönlich natürlich mehr über positives Feedback 🙂

  • Restic UI - QThread

    Restic UI
    1
    0 Stimmen
    1 Beiträge
    95 Aufrufe
    Niemand hat geantwortet
  • 0 Stimmen
    2 Beiträge
    179 Aufrufe
    FrankMF

    Die REST Unterstützung ist komplett 🤓

    Link Preview Image Not Found

    favicon

    (gitlab.com)

    Ich denke, ein wenig Dokumentation wäre noch gut ☺

  • Python3 - subprocess.run

    Python3
    2
    0 Stimmen
    2 Beiträge
    176 Aufrufe
    FrankMF

    Ich möchte das Thema noch mal ausgraben. Bin beim Recherchieren über diese Links gestolpert, die mein Interesse geweckt haben.

    Link Preview Image Python Pipes to Avoid Shells — OpenStack Security Advisories 0.0.1.dev266 documentation

    favicon

    (security.openstack.org)

    B603: subprocess_without_shell_equals_true — Bandit documentation

    favicon

    (bandit.readthedocs.io)

    Da ich aktuell nur eine Desktop Anwendung entwickle, ist das Thema Sicherheit nicht ganz so wichtig, weil wer hackt sich schon selber!? Aber, da man ja nie weiß, wie so ein Tool evt. mal benutzt wird, sollte man von Anfang an auf ein paar Dinge achten.

    Ok, schauen wir uns das mal genauer an.

    Link 1 - shell=True

    Ich kopiere mal das Beispiel aus dem Link.

    def count_lines(website): return subprocess.check_output('curl %s | wc -l' % website, shell=True)

    Ok, das Problem ist

    shell=True

    Ein Beispiel aus meinem Projekt

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

    Gesetzt wird der in meinem Beispiel nicht. Besuchen wir mal die Webseite vom subprocess.run

    https://docs.python.org/3/library/subprocess.html?highlight=subprocess run#subprocess.run

    Wenn ich das jetzt richtig verstehe,

    subprocess.run(args, *, stdin=None, input=None, stdout=None, stderr=None, capture_output=False, shell=False, cwd=None, timeout=None, check=False, encoding=None, errors=None, text=None, env=None, universal_newlines=None, **other_popen_kwargs)

    dann ist standardmäßig

    shell=False

    gesetzt. Damit ist das in meinem Projekt kein Problem.

    Link 2 - B603: subprocess_without_shell_equals_true

    Ein Tool auf gitlab.com wirft Security Warnings aus, dabei war diese. Schauen wir mal, was uns das sagen möchte.

    Python possesses many mechanisms to invoke an external executable. However, doing so may present a security issue if appropriate care is not taken to sanitize any user provided or variable input.

    Ok, es geht also um die Prüfung von Eingaben bzw. Variablen. Der Merksatz "Keine Benutzereingabe wird ungeprüft übernommen!" ist doch mit das Wichtigste, wenn man irgendwas programmiert. Nochmal mein Beispiel von oben.

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

    Ich übergebe dem Prozess einige Eingaben / Variablen.

    backup_data[row].repository pass_word.pw[0]

    Lesen wir wieder ein wenig in der Dokumentation von subprocess.run

    args is required for all calls and should be a string, or a sequence of program arguments. Providing a sequence of arguments is generally preferred, as it allows the module to take care of any required escaping and quoting of arguments (e.g. to permit spaces in file names). If passing a single string, either shell must be True (see below) or else the string must simply name the program to be executed without specifying any arguments.

    Das Wichtigste in Kürze Providing a sequence of arguments is generally preferred

    Der Aufruf von subprocess.run erwartet als erste Übergabe args

    subprocess.run(args, *, ....

    Mein Beispiel

    result = subprocess.run(['restic', '-r', backup_data[row].repository, 'stats'], ....

    Das zwischen den eckigen Klammern ist args. Laut der Anleitung ist es empfohlen, das als ein Argument zu übergeben, also so. Somit ist dafür gesorgt, das das Modul die Argumente selbst ein wenig "überwacht".

    as it allows the module to take care of any required escaping and quoting of arguments (e.g. to permit spaces in file names).

    Somit hätten man schon mal was für sie "Sicherheit" getan.

    args = ['restic', '-r', backup_data[row].repository, 'stats'] result = subprocess.run(args, ....

    Man sollte trotzdem auf diese beiden Variablen

    * backup_data[row].repository * pass_word.pw[0]

    ein Auge behalten. Ich denke, das habe ich in meinem Projekt eingehalten, indem ich Pfadangabe mit den Systemwerkzeugen auswählbar mache, keine Texteingaben! Passwörter und andere Bezeichnung werden mit regex auf korrekte Eingaben geprüft usw.

    Fazit

    Wieder viel gelernt und ich denke, es passt so weit alles. Bei der ganzen Spielerei, dann noch entdeckt, das ich im Code dieses Argument drin hatte.

    check=False

    Das ist aber Standard, somit kann das weg. Habe das im kompletten Projekt dann entfernt und mir fällt gerade auf, da der Code immer gleich ist, muss das jetzt eigentlich alles in eine Funktion 😉 Mal auf die ToDo-Liste drauf schreiben.

  • Python3 - PyQt5 Layout

    Python3
    1
    0 Stimmen
    1 Beiträge
    147 Aufrufe
    Niemand hat geantwortet
  • Python3 - String-Operatoren

    Python3
    1
    0 Stimmen
    1 Beiträge
    134 Aufrufe
    Niemand hat geantwortet