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 v0.13.0 released

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

    Der Autor hat meine Anpassungen um ein paar Änderungen erweitert und in sein Repo eingepflegt. Der QtWaitingSpinenr ist jetzt auch 3.10 kompatibel 🤓

    1b268980-92ca-42a4-89a0-a6e4b7ab9378-grafik.png

  • Restic UI - QThread

    Restic UI
    1
    0 Stimmen
    1 Beiträge
    95 Aufrufe
    Niemand hat geantwortet
  • Restic UI - User documentation

    Restic UI
    1
    0 Stimmen
    1 Beiträge
    213 Aufrufe
    Niemand hat geantwortet
  • 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 - String-Operatoren

    Python3
    1
    0 Stimmen
    1 Beiträge
    134 Aufrufe
    Niemand hat geantwortet
  • 0 Stimmen
    5 Beiträge
    722 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.

  • Python3 - Globale Variablen

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