Debian Codegraph @

docs/servers.rst

raw
1 REST Server
2 ===========
3
4 BorgStore includes a simple REST server that can be used to provide remote access
5 to any BorgStore backend.
6
7 It can do some stuff server-side, which is usually not possible when using other
8 cloud storage servers:
9
10 - enforcing permissions
11 - server rejects store operation if content hashsum does not match expected
12 hashsum (from http header X-Content-hash-sha256)
13 - server-side hash computation (e.g. sha256, or blake3 if the optional ``blake3``
14 package is installed on the server) for item content
15 - server-side defragmentation helper (copies blocks to new items)
16
17 Running the server on host:port
18 -------------------------------
19
20 Run a server with a file: backend (for a local directory), using HTTP Basic Authentication::
21
22 borgstore-server-rest --host 127.0.0.1 --port 5618 \
23 --username user --password pass \
24 --backend file:///tmp/teststore
25
26 For production deployments, consider using systemd socket activation
27 (see contrib/server/nginx-systemd/README.md).
28
29 Running the server via stdio
30 ----------------------------
31
32 Run a server with a file: backend (for a local directory), talking http via
33 stdin/stdout, logging via stderr:
34
35 borgstore-server-rest --stdio \
36 --backend file:///tmp/teststore
37
38 Accessing the server from a client
39 ----------------------------------
40
41 The borgstore REST client can then access via::
42
43 http://user:[email protected]:5618/
44
45 or (when using http over stdio):
46
47 rest://user@host:port//tmp/teststore # via ssh, abs. path
48 rest://user@host:port/teststore # via ssh, rel. path
49 rest:////tmp/teststore # locally, without ssh, abs. path
50 rest:///teststore # locally, without ssh, rel. path
51
52 Permissions
53 -----------
54
55 The REST server, when used with the ``posixfs`` backend, supports the same permissions
56 system as that backend (see above).
57
58 If ``--permissions`` is omitted, all operations are allowed.
59 To restrict permissions, pass a JSON-encoded permissions mapping via ``--permissions``.
60
61 Examples:
62
63 Read-only access::
64
65 borgstore-server-rest --host 127.0.0.1 --port 5618 \
66 --username user --password pass \
67 --backend file:///tmp/teststore \
68 --permissions '{"": "lr"}'
69
70 No-delete, no-overwrite (allow adding new items)::
71
72 borgstore-server-rest --host 127.0.0.1 --port 5618 \
73 --username user --password pass \
74 --backend file:///tmp/teststore \
75 --permissions '{"": "lrw"}'
76
77 Full access::
78
79 borgstore-server-rest --host 127.0.0.1 --port 5618 \
80 --username user --password pass \
81 --backend file:///tmp/teststore \
82 --permissions '{"": "lrwWD"}'
83
84 BorgBackup shortcuts
85 ~~~~~~~~~~~~~~~~~~~~
86
87 Instead of hand-crafting a JSON mapping, you can use a named shortcut tailored for
88 `BorgBackup <https://www.borgbackup.org/>`_ repositories:
89
90 ``borgbackup-all``
91 No permission restrictions — all operations are allowed (equivalent to omitting ``--permissions``).
92
93 ``borgbackup-no-delete``
94 Prevent deletion and overwriting of existing objects; new objects may still be added.
95
96 ``borgbackup-write-only``
97 Clients may store new data but cannot read existing data back (except for caches and metadata
98 that borg needs internally).
99
100 ``borgbackup-read-only``
101 Clients may only list and read objects.
102
103 Example — restrict a backup server to no-delete access:
104
105 .. code-block:: bash
106
107 borgstore-server-rest --host 127.0.0.1 --port 5618 \
108 --username user --password pass \
109 --backend file:///home/user/repos/repo1 \
110 --permissions borgbackup-no-delete
111
112 Custom JSON permissions
113 ~~~~~~~~~~~~~~~~~~~~~~~
114
115 You can also pass an arbitrary JSON-encoded permissions mapping directly.
116
117 Hierarchical rules (list-only at root, read/write in ``data/``)::
118
119 borgstore-server-rest --host 127.0.0.1 --port 5618 \
120 --username user --password pass \
121 --backend file:///tmp/teststore \
122 --permissions '{"": "l", "data": "lrw"}'
123
124 Quota
125 -----
126
127 The REST server, when used with the ``file:`` backend, optionally supports
128 quota tracking and enforcement.
129
130 Use the ``--quota`` argument to set a maximum storage size in bytes (default is
131 no quota tracking and enforcement).
132
133 When the quota is exceeded, ``store`` operations are rejected with HTTP 507
134 (Insufficient Storage).
135
136 Example — limit storage to 1 GiB:
137
138 .. code-block:: bash
139
140 borgstore-server-rest --host 127.0.0.1 --port 5618 \
141 --username user --password pass \
142 --backend file:///tmp/teststore \
143 --quota 1073741824
144