Skip to content

Restic & Rclone & Nextcloud

Linux
  • Ich hatte mich schon mal mit rclone beschäftigt -> https://forum.frank-mankel.org/topic/27/restic-ein-backupkonzept-automatisieren?_=1584115522317

    Was ist rclone?

    Rclone - rsync for cloud storage

    Nun mal rclone auf meinem Haupt-PC, Debian Buster, ausprobieren.

    Installation

    root@debian:~# apt install rclone
    Paketlisten werden gelesen... Fertig
    Abhängigkeitsbaum wird aufgebaut.       
    Statusinformationen werden eingelesen.... Fertig
    Die folgenden NEUEN Pakete werden installiert:
      rclone
    0 aktualisiert, 1 neu installiert, 0 zu entfernen und 0 nicht aktualisiert.
    Es müssen 6.248 kB an Archiven heruntergeladen werden.
    Nach dieser Operation werden 26,6 MB Plattenplatz zusätzlich benutzt.
    Holen:1 https://deb.debian.org/debian buster/main amd64 rclone amd64 1.45-3 [6.248 kB]
    Es wurden 6.203 kB in 8 s geholt (777 kB/s).
    Vormals nicht ausgewähltes Paket rclone wird gewählt.
    (Lese Datenbank ... 238249 Dateien und Verzeichnisse sind derzeit installiert.)
    Vorbereitung zum Entpacken von .../rclone_1.45-3_amd64.deb ...
    Entpacken von rclone (1.45-3) ...
    rclone (1.45-3) wird eingerichtet ...
    

    Konfiguration

    root@debian:~# rclone config
    2020/03/14 09:20:19 NOTICE: Config file "/root/.config/rclone/rclone.conf" not found - using defaults
    No remotes found - make a new one
    n) New remote
    s) Set configuration password
    q) Quit config
    n/s/q> n
    name> nextcloud
    Type of storage to configure.
    Enter a string value. Press Enter for the default ("").
    Choose a number from below, or type in your own value
     1 / A stackable unification remote, which can appear to merge the contents of several remotes
       \ "union"
     2 / Alias for a existing remote
       \ "alias"
     3 / Amazon Drive
       \ "amazon cloud drive"
     4 / Amazon S3 Compliant Storage Providers (AWS, Ceph, Dreamhost, IBM COS, Minio)
       \ "s3"
     5 / Backblaze B2
       \ "b2"
     6 / Box
       \ "box"
     7 / Cache a remote
       \ "cache"
     8 / Dropbox
       \ "dropbox"
     9 / Encrypt/Decrypt a remote
       \ "crypt"
    10 / FTP Connection
       \ "ftp"
    11 / Google Cloud Storage (this is not Google Drive)
       \ "google cloud storage"
    12 / Google Drive
       \ "drive"
    13 / Hubic
       \ "hubic"
    14 / JottaCloud
       \ "jottacloud"
    15 / Local Disk
       \ "local"
    16 / Microsoft Azure Blob Storage
       \ "azureblob"
    17 / Microsoft OneDrive
       \ "onedrive"
    18 / OpenDrive
       \ "opendrive"
    19 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
       \ "swift"
    20 / Pcloud
       \ "pcloud"
    21 / SSH/SFTP Connection
       \ "sftp"
    22 / Webdav
       \ "webdav"
    23 / Yandex Disk
       \ "yandex"
    24 / http Connection
       \ "http"
    Storage> 22
    ** See help for webdav backend at: https://rclone.org/webdav/ **
    
    URL of http host to connect to
    Enter a string value. Press Enter for the default ("").
    Choose a number from below, or type in your own value
     1 / Connect to example.com
       \ "https://example.com"
    url> https://nextcloud.example.de/remote.php/dav/files/User/
    Name of the Webdav site/service/software you are using
    Enter a string value. Press Enter for the default ("").
    Choose a number from below, or type in your own value
     1 / Nextcloud
       \ "nextcloud"
     2 / Owncloud
       \ "owncloud"
     3 / Sharepoint
       \ "sharepoint"
     4 / Other site/service or software
       \ "other"
    vendor> 1
    User name
    Enter a string value. Press Enter for the default ("").
    user> Frank
    Password.
    y) Yes type in my own password
    g) Generate random password
    n) No leave this optional password blank
    y/g/n> y
    Enter the password:
    password:
    Confirm the password:
    password:
    Bearer token instead of user/pass (eg a Macaroon)
    Enter a string value. Press Enter for the default ("").
    bearer_token> 
    Remote config
    --------------------
    [nextcloud]
    url = https://nextcloud.example.de/remote.php/dav/files/Frank/
    vendor = nextcloud
    user = Frank
    pass = *** ENCRYPTED ***
    --------------------
    y) Yes this is OK
    e) Edit this remote
    d) Delete this remote
    y/e/d> y
    Current remotes:
    
    Name                 Type
    ====                 ====
    nextcloud            webdav
    
    e) Edit existing remote
    n) New remote
    d) Delete remote
    r) Rename remote
    c) Copy remote
    s) Set configuration password
    q) Quit config
    e/n/d/r/c/s/q> q
    

    Das sollte für Euch als Nextcloud User keine besondere Herausforderung sein. Unter https://nextcloud.example.de/settings/user/security legt ihr, wie gewohnt, das Gerät fest was auf Eure Nextcloud Instanz zugreifen darf.

    Test

    rclone ls nextcloud:
    

    Ein erster Test gab mir den kompletten Inhalt der Nextcloud Installation aus. Hmm, nicht das was ich wollte. rclone soll nur auf ein bestimmtes Verzeichnis zugreifen dürfen. Also schnell einen Ordner in der Nextcloud angelegt.

    Kurz ändern.

    root@debian:~# rclone config
    Current remotes:
    
    Name                 Type
    ====                 ====
    nextcloud            webdav
    
    e) Edit existing remote
    n) New remote
    d) Delete remote
    r) Rename remote
    c) Copy remote
    s) Set configuration password
    q) Quit config
    e/n/d/r/c/s/q> e
    Choose a number from below, or type in an existing value
     1 > nextcloud
    remote> 1
    --------------------
    [nextcloud]
    type = webdav
    url = https://nextcloud.example.de/remote.php/dav/files/Frank/
    vendor = nextcloud
    user = Frank
    pass = *** ENCRYPTED ***
    --------------------
    Edit remote
    ** See help for webdav backend at: https://rclone.org/webdav/ **
    
    Value "url" = "https://nextcloud.example.de/remote.php/dav/files/Frank/"
    Edit? (y/n)>
    y) Yes
    n) No
    y/n> y
    URL of http host to connect to
    Enter a string value. Press Enter for the default ("").
    Choose a number from below, or type in your own value
     1 / Connect to example.com
       \ "https://example.com"
    url> https://nextcloud.example.de/remote.php/dav/files/Frank/rclone/                                          
    Value "vendor" = "nextcloud"
    Edit? (y/n)>
    y) Yes
    n) No
    y/n> n
    Value "user" = "Frank"
    Edit? (y/n)>
    y) Yes
    n) No
    y/n> n
    Value "pass" = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    Edit? (y/n)>
    y) Yes
    n) No
    y/n> n
    Value "bearer_token" = ""
    Edit? (y/n)>
    y) Yes
    n) No
    y/n> n
    --------------------
    [nextcloud]
    type = webdav
    url = https://nextcloud.example.de/remote.php/dav/files/Frank/rclone/
    vendor = nextcloud
    user = Frank
    pass = *** ENCRYPTED ***
    --------------------
    y) Yes this is OK
    e) Edit this remote
    d) Delete this remote
    y/e/d> y
    Remote config
    Current remotes:
    
    Name                 Type
    ====                 ====
    nextcloud            webdav
    
    e) Edit existing remote
    n) New remote
    d) Delete remote
    r) Rename remote
    c) Copy remote
    s) Set configuration password
    q) Quit config
    e/n/d/r/c/s/q> q
    

    Erneuter Test

    root@debian:~# rclone ls nextcloud:
    

    Jetzt zeigt er ein leeres Verzeichnis an. Kurz ein Dokument erstellt.

    root@debian:~# rclone ls nextcloud:
             4 Testing.md
    

    Passt. Die rclone Konfiguration ist abgeschlossen. Jetzt kann ich mit rclone auf meine Nextcloud Installation zugreifen. Und wofür das Ganze? Mit Restic, in Verbindung mit rclone, möchte ich eine Datensicherung einrichten die Daten verschlüsselt in meiner Nextcloud Instanz ablegt.

  • Gut, nun zum Restic Teil.

    In Debian Buster ist aktuell diese Version enthalten.

    restic/stable,now 0.9.4+ds-2+b1 amd64  [installiert]
      backup program with multiple revisions, encryption and more
    

    Installation

    apt install restic
    

    Version checken mit

    root@debian:~# restic version
    restic 0.9.4 compiled with go1.11.6 on linux/amd64
    

    INIT

    Um jetzt eine Datensicherung zu initialisieren, muss man folgendes eingeben.

    root@debian:~# restic -r rclone:nextcloud:HOME init
    enter password for new repository: 
    enter password again: 
    created restic repository 4bxxxxxx16 at rclone:nextcloud:HOME
    
    Please note that knowledge of your password is required to access
    the repository. Losing your password means that your data is
    irrecoverably lost.
    

    In diesem Beispiel erzeuge ich eine Datensicherung in der Nextcloud Instanz im Verzeichnis HOME.

    8b0322e0-0896-4167-8d25-6e341a61d461-image.png

    Man wird nach dem Passwort gefragt, alles so wie wir es kennen. Mehr zu Restic gibt es hier. Man könnte jetzt natürlich auch mehrere Datensicherungen dort ablegen, dazu müsste das HOME gegen was anderes ausgetauscht werden.

    Backup Plan

    Ich möchte die wichtigsten Daten aus meinem Homeverzeichnis sichern. Dazu müssen wir uns Gedanken machen, was wichtig ist.

    Ich habe da folgende Sachen mal ausgesucht

    • Scripte_NAS
    • .cinnamon
    • .config
    • .filezilla
    • .gnupg
    • .joplin
    • .mozilla
    • .ssh
    • .thunderbird
    • .vscode

    Nun erstellen wir eine INCLUDE Datei.

     nano includes.txt
    

    Die Dateien von oben rein und speichern.

    BACKUP

    Das sieht dann so aus.

    restic --password-file /root/passwd -r rclone:nextcloud:HOME backup --files-from /root/includes.txt
    

    In /root/passwd liegt das Passwort, wir wollen das Ganze ja bitte schön automatisieren.

    Der Rest sollte klar sein, ansonsten verweise ich auf die tolle Anleitung.

    Nun werden alle Dateien verschlüsselt in der Nextcloud Instanz abgelegt. So mit kann auch kein neugieriger Systemadministrator da was mit anfangen 😉

  • Hier mal eine Ausgabe vom ersten Durchgang

    root@frank-MS-7C37:~# restic --password-file /root/passwd -r rclone:Nextcloud:HOME_UBUNTU backup --files-from /root/includes.txt
    repository 99xxxxa0 opened successfully, password is correct
    created new cache in /root/.cache/restic
    rclone: 2020/05/08 17:47:57 ERROR : locks: error listing: directory not found
    rclone: 2020/05/08 17:47:58 ERROR : index: error listing: directory not found
    rclone: 2020/05/08 17:47:58 ERROR : snapshots: error listing: directory not found
    
    Files:        3503 new,     0 changed,     0 unmodified
    Dirs:            2 new,     0 changed,     0 unmodified
    Added to the repo: 16.872 GiB
    
    processed 3503 files, 21.134 GiB in 1:02:56
    snapshot fdxxxxec saved
    

    Der erste Durchgang hat also etwa eine Stunde benötigt. Durch die Deduplikation der Daten, ist der Vorgang beim zweiten Durchgang viel schneller weil nur neue oder geänderte Daten gesichert werden. Und außerdem sind alle Daten AES-256 verschlüsselt. Also perfekt zur Ablage in irgendeiner Cloud 😉

    root@frank-MS-7C37:~# restic --password-file /root/passwd -r rclone:Nextcloud:HOME_UBUNTU backup --files-from /root/includes.txt
    repository 99xxxxa0 opened successfully, password is correct
    
    Files:          57 new,    41 changed,  3449 unmodified
    Dirs:            0 new,     2 changed,     0 unmodified
    Added to the repo: 22.941 MiB
    
    processed 3547 files, 21.137 GiB in 0:13
    snapshot c6xxxxe4 saved
    

    Wie ihr seht, hat der zweite Durchgang nur ein paar neue und geänderte Daten gesichert. Der Rest ist ja schon vorhanden. Und das kann man dann auch problemlos täglich, wöchentlich oder was auch immer mal eben schnell durchführen.

    Eines meiner absoluten Lieblingstool 🙂

  • Redis ändert das Lizenz Modell

    Redis
    2
    0 Votes
    2 Posts
    53 Views
    FrankMF

    Ein Artikel von Heise zum Thema

    Link Preview Image Datenbankanbieter Redis ändert sein Lizenzmodell – erneut

    Die No-SQL-Datenbank wird künftig nach einem dualen Modell lizenziert: Redis Source Available License Version 2 oder Server-Side Public License Version 1.​

    favicon

    Developer (www.heise.de)

  • Restic v0.16.2

    Linux
    1
    0 Votes
    1 Posts
    97 Views
    No one has replied
  • Zima Board

    Linux
    6
    0 Votes
    6 Posts
    653 Views
    FrankMF

    Wer noch einen braucht, sind wieder ein paar im Shop erhältlich.

    ZimaBoard 832 is IN STOCK & AVAILABLE NOW
    ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌
    ZimaBoard Official Store

    Back In Stock

    The item you've been waiting for is back in stock

    ZimaBoard 832 - Single Board Server for Creators

    $199.90

    Model: ZimaBoard 832

    Stock: 190

  • Docker & Redis Datenbank

    Moved Linux
    2
    0 Votes
    2 Posts
    150 Views
    FrankMF

    @FrankM sagte in Docker & Redis Datenbank:

    save 60 1
    #save 900 1
    save 300 10
    save 60 10000

    Hier kann man auch noch schön sehen, wie ich gekämpft habe, bis ich mal eine dump.rdb gesehen habe. Auch irgendwie logisch, das ich nie eine gesehen hatte, wenn man weiß das

    save 900 1

    bedeutet, das er alle 900 Sekunden speichert, wenn mindestens eine Änderung vorhanden ist. Das kann dann schon was dauern. Ich habe das dann mal verkürzt, damit ich schneller ein Ergebnis habe.

    save 60 1

    Das brachte mich dann dem Ziel näher. Danach konnte ich die dump.rdb auch finden.

    Bitte keine Redis DB ohne Passwort laufen lassen!
  • Python & Redis-Datenbank

    Moved Linux
    3
    0 Votes
    3 Posts
    94 Views
    FrankMF

    Heute dann die nächste Herausforderung. Mein JSON soll so aussehen, damit ich das entsprechend erweitern kann.

    Stocks {0: {'stockname': 'Deutsche Telekom Aktie', 'wkn1': '4534543534', 'wkn2': 'sfsdfsdfsfdfd', 'quantity': 100}, 1: {'stockname': 'Henkel', 'wkn1': '4534543534', 'wkn2': 'sfsdfsdfsfdfd', 'quantity': 50}}

    Die Daten sollen wie oben schon ausprobiert, in einer Redis Datenbank liegen. So weit auch kein großes Problem. ABER, der Zugriff auf diese Daten war dann meine nächste Hürde 🙂

    Ok, ich habe also mehrere Einträge im JSON File bzw. in der Datenbank. Wie komme ich da nun wieder dran. Ein paar ☕ später dann die Lösung.

    Wie komme ich an den einzelnen Eintrag, also über den Index??

    r1.json().get('stocks', 1)

    Gibt als Ergebnis

    {'stockname': 'Henkel', 'wkn1': '4534543534', 'wkn2': 'sfsdfsdfsfdfd', 'quantity': 50}

    Ok, das passt schon mal. Somit kann man dann gewohnt auf die einzelnen Elemente zugreifen.

    print("TESTING", testing['stockname'])

    Ausgabe

    TESTING Henkel

    Ok, Teil 1 erledigt. Jetzt habe ich ja irgendwann mehrere Elemente in der Liste und brauch dann den letzten Index , um damit was machen zu können. Also, z.B. durch die Daten zu loopen.

    objkeys = r1.json().objkeys('stocks') print("Objkeys", objkeys)

    Ausgabe

    Objkeys ['0', '1']

    Ok, kommt eine Liste des Index zurück. Damit kann man arbeiten 😉

    Ich hatte dann zum Testen mittels einer while Schleife die Daten geladen, aber jetzt beim Tippen klingelt es und wir machen das schön mit enumerate 😉

    @staticmethod def load(): data = {} for count, value in enumerate(objkeys): testing = r1.json().get('stocks', count) data[count] = { "stockname": testing['stockname'], "wkn1": testing['wkn1'], "wkn2": testing['wkn2'], "quantity": testing['quantity']} return data

    Somit habe ich die Daten aus der Redis Datenbank in einem Objekt und kann damit arbeiten.

  • Kopia - Mit Snapshots arbeiten

    Kopia
    2
    0 Votes
    2 Posts
    341 Views
    FrankMF

    Solltet Ihr mal snaps mit dem Status incomplete haben und möchtet diese loswerden

    :~$ kopia snap ls -i USER@HOST:/home/frank 2020-09-10 16:31:45 CEST k89770cab1061e00ada49efc41075ed34 incomplete:canceled 728.8 MB drwxr-xr-x files:8891 dirs:3033 (incomplete) 2020-09-10 16:40:05 CEST k27f028b63299983167cb0b4a0c85df80 incomplete:canceled 153.8 MB drwxr-xr-x files:1052 dirs:324 (incomplete)

    So was passiert z.B. wenn die Internetleitung rumzickt. Jarek meint, das wäre nicht schlimm, beim nächsten Snapshot wird das gefixt und die Daten genutzt, die schon verarbeitet wurden.

  • Linux Befehle - ls & tail

    Linux
    1
    0 Votes
    1 Posts
    328 Views
    No one has replied
  • 0 Votes
    2 Posts
    1k Views
    FrankMF

    Nachdem ich den ROCKPro64 jetzt auf den Mainline umgestellt habe, lief meine Testinstallation von Grav nicht mehr.

    Hilfreiche Sache um das Problem zu lösen -> https://gist.github.com/GhazanfarMir/03bd1f1f770a3834d47274586d46ea62

    Ich bekam immer 502 Bad Gateway, Grund war ein nicht korrekt gestarteter php-pfm Service.

    rock64@rockpro64v2_0:/usr/local/bin$ sudo service php7.2-fpm start rock64@rockpro64v2_0:/usr/local/bin$ sudo service php7.2-fpm status ● php7.2-fpm.service - The PHP 7.2 FastCGI Process Manager Loaded: loaded (/lib/systemd/system/php7.2-fpm.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2018-08-16 20:15:20 CEST; 21s ago Docs: man:php-fpm7.2(8) Main PID: 3206 (php-fpm7.2) Status: "Processes active: 0, idle: 2, Requests: 3, slow: 0, Traffic: 0.2req/sec" Tasks: 3 (limit: 4622) CGroup: /system.slice/php7.2-fpm.service ├─3206 php-fpm: master process (/etc/php/7.2/fpm/php-fpm.conf) ├─3207 php-fpm: pool www └─3208 php-fpm: pool www Aug 16 20:15:19 rockpro64v2_0 systemd[1]: Starting The PHP 7.2 FastCGI Process Manager... Aug 16 20:15:20 rockpro64v2_0 systemd[1]: Started The PHP 7.2 FastCGI Process Manager.