Skip to content

Rest-Server

Verschoben Restic
8 1 767
  • Was das?

    Rest Server is a high performance HTTP server that implements restic's REST backend API. It provides secure and efficient way to backup data remotely, using restic backup client via the rest: URL.

    Installation

    Mittels git das Repo clonen.

    root@rockpro64:~# git clone https://github.com/restic/rest-server.git
    Cloning into 'rest-server'...
    remote: Enumerating objects: 3, done.
    remote: Counting objects: 100% (3/3), done.
    remote: Compressing objects: 100% (3/3), done.
    remote: Total 3180 (delta 0), reused 2 (delta 0), pack-reused 3177
    Receiving objects: 100% (3180/3180), 5.63 MiB | 2.39 MiB/s, done.
    Resolving deltas: 100% (1189/1189), done.
    

    In das Verzeichnis wechseln und mittels go das File bauen. Moment, go fehlt uns noch.

    apt install golang-go
    

    Danach

     cd rest-server
    

    File bauen

    root@rockpro64:~/rest-server# go run build.go
    go: finding github.com/prometheus/client_golang v0.8.0
    go: finding github.com/prometheus/procfs v0.0.0-20180212145926-282c8707aa21
    go: finding github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a
    go: finding github.com/golang/protobuf v1.0.0
    go: finding github.com/gorilla/handlers v1.3.0
    go: finding github.com/inconshreveable/mousetrap v1.0.0
    go: finding github.com/miolini/datacounter v0.0.0-20171104152933-fd4e42a1d5e0
    go: finding golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a
    go: finding golang.org/x/crypto v0.0.0-20180214000028-650f4a345ab4
    go: finding github.com/spf13/pflag v1.0.0
    go: finding github.com/matttproud/golang_protobuf_extensions v1.0.0
    go: finding github.com/spf13/cobra v0.0.1
    go: finding github.com/prometheus/client_model v0.0.0-20171117100541-99fa1f4be8e5
    go: finding github.com/prometheus/common v0.0.0-20180110214958-89604d197083
    go: finding goji.io v2.0.2+incompatible
    go: downloading github.com/spf13/cobra v0.0.1
    go: downloading github.com/gorilla/handlers v1.3.0
    go: downloading goji.io v2.0.2+incompatible
    go: downloading golang.org/x/crypto v0.0.0-20180214000028-650f4a345ab4
    go: downloading github.com/prometheus/client_golang v0.8.0
    go: downloading github.com/miolini/datacounter v0.0.0-20171104152933-fd4e42a1d5e0
    go: downloading github.com/spf13/pflag v1.0.0
    go: downloading github.com/prometheus/common v0.0.0-20180110214958-89604d197083
    go: downloading github.com/prometheus/client_model v0.0.0-20171117100541-99fa1f4be8e5
    go: downloading github.com/golang/protobuf v1.0.0
    go: downloading github.com/prometheus/procfs v0.0.0-20180212145926-282c8707aa21
    go: downloading github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a
    go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.0
    

    Das resultierende File rest-server an seinen Platz verschieben.

    cp rest-server /usr/local/bin   
    

    Test

    root@rockpro64:/# rest-server --help
    Run a REST server for use with restic
    
    Usage:
      rest-server [flags]
    
    Flags:
          --append-only          enable append only mode
          --cpu-profile string   write CPU profile to file
          --debug                output debug messages
      -h, --help                 help for rest-server
          --listen string        listen address (default ":8000")
          --log string           log HTTP requests in the combined log format
          --max-size int         the maximum size of the repository in bytes
          --no-auth              disable .htpasswd authentication
          --path string          data directory (default "/tmp/restic")
          --private-repos        users can only access their private repo
          --prometheus           enable Prometheus metrics
          --tls                  turn on TLS support
          --tls-cert string      TLS certificate path
          --tls-key string       TLS key path
      -V, --version              output version and exit
    

    Gut, das Programm läuft 🙂

    Rest-Server starten

    root@rockpro64:/# rest-server --path /home/rock64/backup --no-auth
    Data directory: /home/rock64/backup
    Authentication disabled
    Private repositories disabled
    Starting server on :8000
    

    OK, der Rest-Server läuft. Dann mal ausprobieren.

    Backup erstellen und Test

    Init

    root@frank-MS-7C37:~# restic -r rest:http://192.168.3.11:8000/ init
    enter password for new repository: 
    enter password again: 
    created restic repository 394364201c at rest:http://192.168.3.11:8000/
    
    Please note that knowledge of your password is required to access
    the repository. Losing your password means that your data is
    irrecoverably lost.
    

    backup

    root@frank-MS-7C37:~# restic -r rest:http://192.168.3.11:8000/ backup /home/frank/Dokumente/
    enter password for repository: 
    repository 39436420 opened successfully, password is correct
    created new cache in /root/.cache/restic
    
    Files:          27 new,     0 changed,     0 unmodified
    Dirs:            2 new,     0 changed,     0 unmodified
    Added to the repo: 6.218 MiB
    
    processed 27 files, 6.217 MiB in 0:00
    snapshot ad49233b saved
    

    und noch einer

    root@frank-MS-7C37:~# restic -r rest:http://192.168.3.11:8000/ backup /home/frank/Bilder/
    enter password for repository: 
    repository 39436420 opened successfully, password is correct
    
    Files:         432 new,     0 changed,     0 unmodified
    Dirs:            2 new,     0 changed,     0 unmodified
    Added to the repo: 1.180 GiB
    
    processed 432 files, 1.237 GiB in 0:16
    snapshot ed35bfe7 saved
    

    snapshots

    root@frank-MS-7C37:~# restic -r rest:http://192.168.3.11:8000/ snapshots
    enter password for repository: 
    repository 39436420 opened successfully, password is correct
    ID        Time                 Host           Tags        Paths
    -------------------------------------------------------------------------------
    ad49233b  2020-05-10 09:48:10  frank-MS-7C37              /home/frank/Dokumente
    ed35bfe7  2020-05-10 09:48:38  frank-MS-7C37              /home/frank/Bilder
    -------------------------------------------------------------------------------
    2 snapshots
    

    Rest-Server

    Auf dem Rest-Server liegen die Daten in dem angegebenen Verzeichnis --path /home/rock64/backup

    root@rockpro64:/# ls -lha /home/rock64/backup/
    total 32K
    drwxr-xr-x   7 root   root   4.0K May 10 09:47 .
    drwxr-xr-x   5 rock64 rock64 4.0K May 10 09:43 ..
    -rw-------   1 root   root    155 May 10 09:47 config
    drwx------ 258 root   root   4.0K May 10 09:47 data
    drwx------   2 root   root   4.0K May 10 09:49 index
    drwx------   2 root   root   4.0K May 10 09:47 keys
    drwx------   2 root   root   4.0K May 10 09:49 locks
    drwx------   2 root   root   4.0K May 10 09:49 snapshots
    

    User Authentifizierung

    Zur Benutzerauthentifizierung benutzt der Rest-Server das Tool htpasswd, dazu muss folgendes installiert sein.

    apt install apache2-utils
    

    Danach kann man im Backup Pfad die .htaccess anlegen.

    root@rockpro64:/home/rock64/backup# htpasswd -B -c .htpasswd frank   
    New password: 
    Re-type new password: 
    Adding password for user frank
    

    Sieht dann im Verzeichnis so aus.

    root@rockpro64:/home/rock64/backup# ls -lha
    total 36K
    drwxr-xr-x   7 root   root   4.0K May 10 10:16 .
    drwxr-xr-x   5 rock64 rock64 4.0K May 10 09:43 ..
    -rw-r--r--   1 root   root     67 May 10 10:17 .htpasswd
    -rw-------   1 root   root    155 May 10 09:47 config
    drwx------ 258 root   root   4.0K May 10 09:47 data
    drwx------   2 root   root   4.0K May 10 09:49 index
    drwx------   2 root   root   4.0K May 10 09:47 keys
    drwx------   2 root   root   4.0K May 10 10:18 locks
    drwx------   2 root   root   4.0K May 10 09:49 snapshots
    

    Man kann jetzt, auf dieses Verzeichnis, nur noch drauf zugreifen wenn man sich mit USER und PASSWORD authentifiziert.

    Server Start

    root@rockpro64:/home/rock64/backup# rest-server --path /home/rock64/backup          
    Data directory: /home/rock64/backup
    Authentication enabled
    Private repositories disabled
    Starting server on :8000
    

    Server Zugriff

    root@frank-MS-7C37:~# restic -r rest:http://USER:PASSWORD@192.168.3.11:8000/ snapshots
    enter password for repository: 
    repository 39436420 opened successfully, password is correct
    ID        Time                 Host           Tags        Paths
    -------------------------------------------------------------------------------
    ad49233b  2020-05-10 09:48:10  frank-MS-7C37              /home/frank/Dokumente
    ed35bfe7  2020-05-10 09:48:38  frank-MS-7C37              /home/frank/Bilder
    -------------------------------------------------------------------------------
    2 snapshots
    
  • Und noch zwei Dinge, die interessant sind und noch ausprobiert werden müssen 😉

    The --append-only mode allows creation of new backups but prevents deletion and modification of existing backups. This can be useful when backing up systems that have a potential of being hacked.

    To prevent your users from accessing each others' repositories, you may use the --private-repos flag which grants access only when a subdirectory with the same name as the user is specified in the repository URL. For example, user "foo" using the repository URLs rest:https://foo:pass@host:8000/foo or rest:https://foo:pass@host:8000/foo/ would be granted access, but the same user using repository URLs rest:https://foo:pass@host:8000/ or rest:https://foo:pass@host:8000/foobar/ would be denied access.

  • --append-only

    Schützt Backups vor diesen fiesen Dinger, wie heißen die noch in der Windows Welt? Emotet oder so? 🙂

    Server starten

    root@rockpro64:/home/rock64/backup# rest-server --path /home/rock64/backup --append-only
    Data directory: /home/rock64/backup
    Authentication enabled
    Private repositories disabled
    Starting server on :8000
    

    Snapshots

    root@frank-MS-7C37:~# restic -r rest:http://USER:PASSWORD@192.168.3.11:8000/ snapshots
    enter password for repository: 
    repository 39436420 opened successfully, password is correct
    ID        Time                 Host           Tags        Paths
    -------------------------------------------------------------------------------
    ad49233b  2020-05-10 09:48:10  frank-MS-7C37              /home/frank/Dokumente
    ed35bfe7  2020-05-10 09:48:38  frank-MS-7C37              /home/frank/Bilder
    -------------------------------------------------------------------------------
    2 snapshots
    

    Snapshot entfernen

    root@frank-MS-7C37:~# restic -r rest:http://USER:PASSWORD@192.168.3.11:8000/ forget ad49233b
    enter password for repository: 
    repository 39436420 opened successfully, password is correct
    Remove(<snapshot/ad49233b1a>) returned error, retrying after 682.09481ms: blob not removed, server response: 403 Forbidden (403)
    Remove(<snapshot/ad49233b1a>) returned error, retrying after 1.019858552s: blob not removed, server response: 403 Forbidden (403)
    Remove(<snapshot/ad49233b1a>) returned error, retrying after 1.508077523s: blob not removed, server response: 403 Forbidden (403)
    Remove(<snapshot/ad49233b1a>) returned error, retrying after 2.060637198s: blob not removed, server response: 403 Forbidden (403)
    Remove(<snapshot/ad49233b1a>) returned error, retrying after 1.967534989s: blob not removed, server response: 403 Forbidden (403)
    Remove(<snapshot/ad49233b1a>) returned error, retrying after 5.102318508s: blob not removed, server response: 403 Forbidden (403)
    Remove(<snapshot/ad49233b1a>) returned error, retrying after 7.165967493s: blob not removed, server response: 403 Forbidden (403)
    Remove(<snapshot/ad49233b1a>) returned error, retrying after 6.624453285s: blob not removed, server response: 403 Forbidden (403)
    Remove(<snapshot/ad49233b1a>) returned error, retrying after 11.304339401s: blob not removed, server response: 403 Forbidden (403)
    

    Ok, funktioniert 🙂

  • IPv6

    root@frank-MS-7C37:~# restic -r rest:http://USER:PASSWORD@[2a02:908:1265:fbf0:xxxx:xxxx:xxxx:xxxx]:8000/ snapshots
    enter password for repository: 
    repository 39436420 opened successfully, password is correct
    ID        Time                 Host           Tags        Paths
    -------------------------------------------------------------------------------
    ad49233b  2020-05-10 09:48:10  frank-MS-7C37              /home/frank/Dokumente
    ed35bfe7  2020-05-10 09:48:38  frank-MS-7C37              /home/frank/Bilder
    -------------------------------------------------------------------------------
    2 snapshots
    
  • iptables

            #=========================
            # Rest-Server zur Firewall erlauben (IN)
            #=========================
            $IP4TABLES -A INPUT -p tcp --dport 8000 -j ACCEPT
            $IP6TABLES -A INPUT -p tcp --dport 8000 -j ACCEPT
    
  • Heute mal was Zeit gehabt zum Spielen. Rest-Server aufgesetzt, mittels Letsencrypt die TLS Verbindung eingerichtet und läuft alles. Bin gerade mal mein Home-Verzeichnis am hochladen. Evt. schreibe ich dazu einen separaten Beitrag.

  • Rest-Server in Version v0.10.0 released. Test folgt die Tage..

  • Dann mal eben ausprobiert. Auf meinem Server war die Version 0.9.7 selber, mit go, gebaut. Dann mache ich das auch mit der v0.10.0 so. Aber bevor ich anfange, wird die v0.9.7 gesichert.

    mv /usr/local/bin/rest-server /usr/local/bin/rest-server_0_9_7
    

    So erspare ich mir im Problemfall das selber bauen.

    Ok, dann die neue Version bauen.

    git clone https://github.com/restic/rest-server.git
    cd rest-server
    go run build.go
    

    Danach befindet sich im Verzeichnis die Binärdatei rest-server

    Die kopieren wir jetzt

    cp rest-server /usr/local/bin
    

    Danach kurzer Test

    # rest-server --version
    rest-server 0.10.0 (v0.10.0-6-g037fe06) compiled with go1.11.6 on linux/amd64
    

    Gut Version passt 🙂

    Dann ein Backup gestartet. Das sichert einen Teil meines Home-Verzeichnis

    Files:         153 new,   100 changed, 177857 unmodified
    Dirs:            0 new,     1 changed,     0 unmodified
    Added to the repo: 81.881 MiB
    
    processed 178110 files, 80.571 GiB in 0:28
    snapshot 607e0027 saved
    Applying Policy: keep the last 3 snapshots, 3 monthly snapshots
    keep 5 snapshots:
    ID        Time                 Host           Tags        Reasons           Paths
    ---------------------------------------------------------------------------------------
    fa97890e  2020-07-25 21:02:05  frank-XXX              monthly snapshot  /home/frank
    5b073bbb  2020-08-30 10:17:27  frank-XXX              monthly snapshot  /home/frank
    f7cf37ef  2020-09-06 15:13:03  frank-XXX              last snapshot     /home/frank
    0157462c  2020-09-13 13:32:12  frank-XXX              last snapshot     /home/frank
    607e0027  2020-09-14 08:09:34  frank-XXX              last snapshot     /home/frank
                                                              monthly snapshot
    ---------------------------------------------------------------------------------------
    5 snapshots
    
    remove 1 snapshots:
    ID        Time                 Host           Tags        Paths
    ---------------------------------------------------------------------
    3010b7cc  2020-09-06 11:39:27  frank-XXX             /home/frank
    ---------------------------------------------------------------------
    1 snapshots
    
    1 snapshots have been removed, running prune
    counting files in repo
    building new index for repo
    [1:34] 100.00%  17351 / 17351 packs
    

    So weit funktioniert das genau wie vorher. Im Changelog stand ja was von Subfoldern. Das betrifft mich nicht, weil ich für jeden User genau ein Verzeichnis habe.

    So mit alles Gut 🙂 Dann warte ich mal morgen ab, ob die täglichen Backups der Server rund laufen.

  • OpenCloud - Storage Backends testen

    OpenCloud opencloud linux docker
    2
    0 Stimmen
    2 Beiträge
    74 Aufrufe
    FrankMF
    So, mal weiter damit beschäftigen. Also, durch meine ganze Testerei war doch ein Haufen Müll angefallen. dockeruser@opencloud:~/opencloud/deployments/examples/opencloud_full$ docker volume ls DRIVER VOLUME NAME local 0fcd6f237898477b251f3dacb6cd083996092b783f991f899b06d89befc41b1e local 1d8df3f5d41613ad93ed753ce2102a14738cf00e8e7d127ec79881660be291ab local 3b612ce20b207c226640d6b84c32c788cd0fad9f9157578c2310f4b3db63dd29 local 5dfdde733fefb9fdb805acec8338a860762e88cd0753f4bb4098a19fbcd4b6c3 local 6bd5659759fb99b0d0613175d2392ca268dbdb3bd0353b85ccdf9a6004e798c0 local 6f8881420aa0e7713ed5308e635fcb9382939b6570afbd1d776866a07f6d61f2 local 29f7d20edd9eda935041cea7af5aab0af748175d7df8f345288463753d2afa9a local 66ca6287706aac5013b458a109e7c143c4fb177670734fc7a0f68495b1c62fd4 local 74d304835ef51f91226cc22dbbd494d2ddc9a4d91badf88814cae24126efd04a local 0203eb654c1f28a60899ded4660fb101ea222a5f8c86a225d39f3e5da877f1c0 local 271c474feb2ed915afb8efa85e422461fcfdf8acd4097355841eadf33847b7ef local 569a8c34804afd5861299973bed023c0146f40c0dbda0d980b8651bbcadc7fc9 local 655b1f446b5db9749787d4be4445887dcb3d19906d4244d059a0f292a6cd5f01 local 843bb8d0d7845adab06e146c44b153b842d5a1a1d8eb3972bdee1d3cbcb7e815 local 987ee19b8639ad5fffabba276ceb1ca09af6ebc66efb007e561570589c9c53a8 local 1004f5b7b161a4fe37a07d7960740e5cd09b90d5744f1922fb3e41c1265f800a local 2043c77b57728106cbcca8b7e2d3ae2f07ddf4ca44ee21fca232526c95e07381 local 3685c81df1be0061352dfc5b0e6db8d8d9f9b0915a271f1ca53d2796a7876805 local 9581abcfb4fb42b2fabfabbc8139cc4659ca83d92a8b60041957565409293ef4 local 796650f1fa887ff0b153822b268a10aa3579f4f2ca3ce6855ff292e49b3bb6b8 local 426251107e3131a250b27b96e795355332127f19ccf1ec8252860aff5d0caec8 local bd43ceef38448db348cc34e7dc5c4fee9c834d8b6c5957b1e6cdb83cec7b0974 local d94e7ce6c0fb1f4f7b811f624b4526ea889f2f8b99d2aa1b21e79d00dfeb38d0 local e87a27c307a8be80839fae1c006273d57570bb99f60c78c95e86a1e9ea1a786c local f2b3e30406db730e2a341850243c115b6eb231f30f41f5353c7b2427de39af75 local opencloud_full_certs local opencloud_full_opencloud-apps local opencloud_full_opencloud-config local opencloud_full_opencloud-data Oje, das sieht ziemlich vermüllt aus. Dann mal ganz mutig alles löschen. Vorher alles gestoppt. docker compose down Volume löschen, nur ein Beispiel docker volume rm opencloud_full_opencloud-data Alles gelöscht. Dann mal ein Neustart docker compose up -d Jetzt sieht das schon viel besser aus. dockeruser@opencloud:~/opencloud/deployments/examples/opencloud_full$ docker volume ls DRIVER VOLUME NAME local 3737a8eab68ffdc08d6e41493346feeb2e06ef350a210213ab450775318e49f8 local opencloud_full_opencloud-apps Da ich neugierig bin, schauen wir mal rein. root@opencloud:~ ls -lha /var/lib/docker/volumes/3737a8eab68ffdc08d6e41493346feeb2e06ef350a210213ab450775318e49f8/_data/web/assets/apps/ total 8.0K drwxr-x--x 2 dockeruser dockeruser 4.0K May 19 18:25 . drwxr-x--x 3 dockeruser dockeruser 4.0K May 31 10:21 .. Vermutlich ein Speicher, wo die Web Apps was ablegen können. Der andere zeigt es dann klarer. root@opencloud-4gb-fsn1-2:~# ls -lha /var/lib/docker/volumes/opencloud_full_opencloud-apps/_data total 28K drwxr-x--x 7 dockeruser dockeruser 4.0K May 31 10:22 . drwx-----x 3 root root 4.0K May 31 10:21 .. drwxr-xr-x 2 root root 4.0K May 31 10:22 draw-io drwxr-xr-x 2 root root 4.0K May 31 10:21 external-sites drwxr-xr-x 3 root root 4.0K May 31 10:22 json-viewer drwxr-xr-x 2 root root 4.0K May 31 10:22 progress-bars drwxr-xr-x 3 root root 4.0K May 31 10:22 unzip Ok, das sollte mir erst mal reichen. Meine Installation lagert die certs ja aus, das habe ich im docker compose geändert. dockeruser@opencloud:~/opencloud/deployments/examples/opencloud_full$ ls -lha certs/ total 44K drwxr-xr-x 2 dockeruser dockeruser 4.0K May 30 05:49 . drwxr-xr-x 6 dockeruser dockeruser 4.0K May 31 10:38 .. -rw------- 1 dockeruser dockeruser 33K May 29 11:00 acme.json Im docker-compose.yml volumes: - ./certs:/certs # bind-mount acme.json Der Grund dafür ist, das ich das docker-compose nicht als root laufen haben möchte. Die Hauptdaten sind nach lokal ausgelagert. OC_CONFIG_DIR=/home/dockeruser/oc_data/config OC_DATA_DIR=/home/dockeruser/oc_data/data Somit sollte jetzt alles so passen und ich muss mal langsam mit der Spielerei aufhören
  • Und dringend einen #OpenCloud Desktop Client für #Linux.

    Uncategorized opencloud linux
    1
    0 Stimmen
    1 Beiträge
    57 Aufrufe
    Niemand hat geantwortet
  • Manjaro Btrfs Snapshot auswählen

    Linux manjaro linux
    1
    2
    0 Stimmen
    1 Beiträge
    412 Aufrufe
    Niemand hat geantwortet
  • Proxmox 8.1 released

    Linux proxmox linux
    1
    0 Stimmen
    1 Beiträge
    162 Aufrufe
    Niemand hat geantwortet
  • NodeBB - 2.8.13 & 3.1.3 Security Release

    NodeBB nodebb linux
    1
    0 Stimmen
    1 Beiträge
    100 Aufrufe
    Niemand hat geantwortet
  • RISC-V

    VisionFive 2 visionfive2 star64 linux
    1
    0 Stimmen
    1 Beiträge
    119 Aufrufe
    Niemand hat geantwortet
  • Restic UI - REST Server Unterstützung

    Restic UI restic-ui restic rest-server python
    2
    0 Stimmen
    2 Beiträge
    304 Aufrufe
    FrankMF
    Die REST Unterstützung ist komplett https://gitlab.com/Bullet64/restic-ui-public/-/releases/1.1.0 Ich denke, ein wenig Dokumentation wäre noch gut
  • Restic - Beispielzeiten

    Restic linux restic
    1
    0 Stimmen
    1 Beiträge
    522 Aufrufe
    Niemand hat geantwortet