borgapi 0.6.1__tar.gz → 0.7.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. {borgapi-0.6.1 → borgapi-0.7.1}/PKG-INFO +68 -42
  2. {borgapi-0.6.1 → borgapi-0.7.1}/README.md +53 -32
  3. borgapi-0.7.1/borgapi/__init__.py +45 -0
  4. {borgapi-0.6.1 → borgapi-0.7.1}/borgapi/borgapi.py +616 -313
  5. borgapi-0.7.1/borgapi/capture.py +416 -0
  6. borgapi-0.7.1/borgapi/helpers.py +26 -0
  7. {borgapi-0.6.1 → borgapi-0.7.1}/borgapi/options.py +137 -68
  8. {borgapi-0.6.1 → borgapi-0.7.1}/borgapi.egg-info/PKG-INFO +68 -42
  9. borgapi-0.7.1/borgapi.egg-info/SOURCES.txt +16 -0
  10. borgapi-0.7.1/borgapi.egg-info/requires.txt +2 -0
  11. {borgapi-0.6.1 → borgapi-0.7.1}/borgapi.egg-info/top_level.txt +0 -1
  12. borgapi-0.7.1/pyproject.toml +75 -0
  13. borgapi-0.7.1/setup.py +5 -0
  14. borgapi-0.7.1/test/__init__.py +1 -0
  15. {borgapi-0.6.1 → borgapi-0.7.1}/test/test_00_options.py +6 -6
  16. borgapi-0.6.1/borgapi/__init__.py +0 -5
  17. borgapi-0.6.1/borgapi.egg-info/SOURCES.txt +0 -30
  18. borgapi-0.6.1/borgapi.egg-info/requires.txt +0 -2
  19. borgapi-0.6.1/setup.py +0 -33
  20. borgapi-0.6.1/test/__init__.py +0 -0
  21. borgapi-0.6.1/test/borgapi/__init__.py +0 -0
  22. borgapi-0.6.1/test/borgapi/test_01_borgapi.py +0 -226
  23. borgapi-0.6.1/test/borgapi/test_02_init.py +0 -78
  24. borgapi-0.6.1/test/borgapi/test_03_create.py +0 -136
  25. borgapi-0.6.1/test/borgapi/test_04_extract.py +0 -52
  26. borgapi-0.6.1/test/borgapi/test_05_rename.py +0 -32
  27. borgapi-0.6.1/test/borgapi/test_06_list.py +0 -59
  28. borgapi-0.6.1/test/borgapi/test_07_diff.py +0 -54
  29. borgapi-0.6.1/test/borgapi/test_08_delete.py +0 -68
  30. borgapi-0.6.1/test/borgapi/test_09_prune.py +0 -48
  31. borgapi-0.6.1/test/borgapi/test_10_info.py +0 -50
  32. borgapi-0.6.1/test/borgapi/test_11_mount.py +0 -50
  33. borgapi-0.6.1/test/borgapi/test_12_key.py +0 -81
  34. borgapi-0.6.1/test/borgapi/test_13_export_tar.py +0 -38
  35. borgapi-0.6.1/test/borgapi/test_14_config.py +0 -42
  36. borgapi-0.6.1/test/borgapi/test_15_benchmark_crud.py +0 -24
  37. borgapi-0.6.1/test/borgapi/test_16_compact.py +0 -33
  38. {borgapi-0.6.1 → borgapi-0.7.1}/LICENSE +0 -0
  39. {borgapi-0.6.1 → borgapi-0.7.1}/borgapi.egg-info/dependency_links.txt +0 -0
  40. {borgapi-0.6.1 → borgapi-0.7.1}/setup.cfg +0 -0
@@ -1,25 +1,30 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: borgapi
3
- Version: 0.6.1
3
+ Version: 0.7.1
4
4
  Summary: Wrapper for borgbackup to easily use in code
5
- Home-page: https://github.com/spslater/borgapi
6
- Author: Sean Slater
7
- Author-email: seanslater@whatno.io
8
- License: MIT License
9
- Keywords: borgbackup backup api
5
+ Author-email: Sean Slater <seanslater@whatno.io>
6
+ Project-URL: homepage, https://github.com/spslater/borgapi
7
+ Project-URL: documentation, https://github.com/spslater/borgapi/blob/master/README.md
8
+ Project-URL: repository, https://github.com/spslater/borgapi.git
9
+ Project-URL: issues, https://github.com/spslater/borgapi/issues
10
+ Project-URL: changelog, https://github.com/spslater/borgapi/blob/master/CHANGELOG.md
11
+ Keywords: borgbackup,backup,api
10
12
  Classifier: Development Status :: 4 - Beta
11
13
  Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.8
13
14
  Classifier: Programming Language :: Python :: 3.9
14
15
  Classifier: Programming Language :: Python :: 3.10
15
16
  Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
16
19
  Classifier: Operating System :: OS Independent
17
- Classifier: License :: OSI Approved :: MIT License
18
20
  Classifier: Topic :: Utilities
19
21
  Classifier: Topic :: System :: Archiving :: Backup
20
- Requires-Python: >=3.8
22
+ Requires-Python: >=3.9
21
23
  Description-Content-Type: text/markdown
22
24
  License-File: LICENSE
25
+ Requires-Dist: borgbackup[llfuse]~=1.4.0
26
+ Requires-Dist: python-dotenv~=1.0.0
27
+ Dynamic: license-file
23
28
 
24
29
  # BorgAPI
25
30
 
@@ -34,10 +39,10 @@ pip install borgapi
34
39
  ```
35
40
 
36
41
  Requires:
37
- * `borgbackup`: 1.2.4
38
- * `python-dotenv`: 1.0.0
42
+ * `borgbackup`: 1.4.0
43
+ * `python-dotenv`: 1.0.1
39
44
 
40
- Supports Python 3.8 to 3.11
45
+ Supports Python 3.9 to 3.13
41
46
 
42
47
  ## Usage
43
48
  ```python
@@ -46,12 +51,12 @@ import borgapi
46
51
  api = borgapi.BorgAPI(defaults={}, options={})
47
52
 
48
53
  # Initalize new repository
49
- api.init("/foo/bar", make_parent_dirs=True)
54
+ api.init("foo/bar", make_parent_dirs=True)
50
55
 
51
56
  # Create backup
52
- result = api.create("/foo/bar::backup", "/home", "/mnt/baz", json=True)
57
+ result = api.create("foo/bar::backup", "/home", "/mnt/baz", json=True)
53
58
  print(result['archive']["name"]) # backup
54
- print(result["repository"]["location"]) # /foo/bar
59
+ print(result["repository"]["location"]) # foo/bar
55
60
  ```
56
61
 
57
62
  ### BorgAPI Init arguments
@@ -60,7 +65,8 @@ class BorgAPI(
60
65
  defaults: dict = None,
61
66
  options: dict = None,
62
67
  log_level: str = "warning",
63
- log_json: bool = False
68
+ log_json: bool = False,
69
+ environ: dict = None,
64
70
  )
65
71
  ```
66
72
  * __defaults__: dictionary that has command names as keys and value that is a dict of
@@ -94,12 +100,35 @@ class BorgAPI(
94
100
  level as and keyword argument
95
101
  * __log_json__: log lines written by logger are formatted as json lines, passed into the
96
102
  logging setup
103
+ * __environ__: dictionary that contains environmental variables that should be set before running
104
+ any commands. Useful for setting the passphrase or passcommand for the repository or other
105
+ settings like that. See [Environment Variables](#Setting-Environment-Variables) section for
106
+ how to set environmental variables after initalization or what the defaults are.
107
+ ```python
108
+ {
109
+ "BORG_CHECK_I_KNOW_WHAT_I_AM_DOING": "YES",
110
+ "BORG_PASSCOMMAND": "cat ~/.borg/password",
111
+ }
112
+ ```
97
113
 
98
114
  ### Setting Environment Variables
99
115
  You are able to manage the environment variables used by borg to be able to use different settings
100
116
  for different repositories.
101
117
 
102
- There are 3 ways you can set the variables:
118
+ When initialzing the `BorgAPI` object, you can include a dictionary with the `environ` argument.
119
+
120
+ The following are the defaults that BorgAPI will always load so that user input does not hold up
121
+ the app from progressing.
122
+ ```ini
123
+ BORG_EXIT_CODES=modern,
124
+ BORG_PASSPHRASE="",
125
+ BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=no,
126
+ BORG_RELOCATED_REPO_ACCESS_IS_OK=no,
127
+ BORG_CHECK_I_KNOW_WHAT_I_AM_DOING=NO,
128
+ BORG_DELETE_I_KNOW_WHAT_I_AM_DOING=NO,
129
+ ```
130
+
131
+ There are 3 ways you can set the variables after initialization:
103
132
  1. `filename`: Path to a file that contains the variables and their values. See the
104
133
  [python-dotenv README](https://github.com/theskumar/python-dotenv/blob/master/README.md#file-format)
105
134
  for more information.
@@ -122,14 +151,6 @@ will be used, which is searching for a ".env" file somewhere above in the curren
122
151
  [Environment Variables](https://borgbackup.readthedocs.io/en/stable/usage/general.html#environment-variables)
123
152
  used by `borgbackup`.
124
153
 
125
- #### IMPORTANT
126
- For commands that borg requires a confirmation on if no environment variable is given, the api will
127
- become stuck as it waits for a `yes` or `no` answer.
128
- * BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK
129
- * BORG_RELOCATED_REPO_ACCESS_IS_OK
130
- * BORG_CHECK_I_KNOW_WHAT_I_AM_DOING
131
- * BORG_DELETE_I_KNOW_WHAT_I_AM_DOING
132
-
133
154
  ### Removing Environment Variables
134
155
  If you want to unset a variable so it doesn't get used for another command you can use the
135
156
  `unset_environ` method. It'll remove any variables passed in from the current environment.
@@ -156,7 +177,7 @@ So the `--storage-quota` argument in `init` gets turned into the keyword argumen
156
177
 
157
178
  ```python
158
179
  api.init(
159
- repository="/foor/bar",
180
+ repository="foor/bar",
160
181
  encryption="repokey",
161
182
  append_only=True,
162
183
  storage_quota="5G",
@@ -173,9 +194,9 @@ diff_args = {
173
194
  }
174
195
 
175
196
  api.diff(
176
- "/foo/bar::tuesday",
197
+ "foo/bar::tuesday",
177
198
  "friday",
178
- "/foo/bar",
199
+ "foo/bar",
179
200
  "/baz",
180
201
  **diff_args,
181
202
  )
@@ -195,20 +216,18 @@ api.diff(
195
216
  * info
196
217
  * mount
197
218
  * umount
198
- * key_change_passphrase (key change-passphrase)
199
- * key_export (key export)
200
- * key_import (key import)
219
+ * key change-passphrase (key_change_passphrase)
220
+ * key export (key_export)
221
+ * key import (key_import)
201
222
  * upgrade
202
- * export_tar
223
+ * recreate
224
+ * immport-tar (immport_tar)
225
+ * export-tar (export_tar)
203
226
  * serve
204
227
  * config
205
- * with-lock
206
- * break-lock
207
- * benchmark crud
208
-
209
- ### Unavailable Borg Commands
210
- * recreate
211
- * Since this is an experimental feature there are no current plans to implament this.
228
+ * with-lock (with_lock)
229
+ * break-lock (break_lock)
230
+ * benchmark crud (benchmark_crud)
212
231
 
213
232
  ### Command Quirks
214
233
  Things that were changed from the way the default borg commands work to make things a bit
@@ -233,7 +252,8 @@ which outputs the stats info as a json object, it gets written to stdout.
233
252
 
234
253
  If either `json` or `log_json` is set, it'll try to convert the tuple output to json.
235
254
  If it is unable and there is output that is captured it'll return the plaintext value.
236
- If no output is captured, it returns `None`.
255
+ If no output is captured, it returns `None` if expecting a string or `{}` (an empty
256
+ dictionary) if expection some kind of JSON output.
237
257
 
238
258
  If multiple outputs are requested at the same time (like `--stats` and `--list`) the command
239
259
  will return a dictionary with aptly named keys (`--list` key is "list"). If only one output
@@ -265,6 +285,12 @@ Commands not listed return no output (None)
265
285
  - info: `--info`
266
286
  - info
267
287
  - always returns bare value
288
+ - recreate:
289
+ - list: `--list`, `--log-json`
290
+ - stats: `--stats`
291
+ - import tar
292
+ - list: `--list`
293
+ - stats: `--stats`, `--json`
268
294
  - export tar
269
295
  - list: `--list`, `--log-json`
270
296
  - tar: filename == "-"
@@ -275,7 +301,7 @@ Commands not listed return no output (None)
275
301
  - always returns bare value
276
302
 
277
303
  ## Roadmap
278
- - Start work on Borg's beta branch chagnes and keeping up with those
304
+ - Start work on Borg's beta branch again and keeping up with those
279
305
 
280
306
  ## Links
281
307
  * [PyPi Project](https://pypi.org/project/borgapi)
@@ -11,10 +11,10 @@ pip install borgapi
11
11
  ```
12
12
 
13
13
  Requires:
14
- * `borgbackup`: 1.2.4
15
- * `python-dotenv`: 1.0.0
14
+ * `borgbackup`: 1.4.0
15
+ * `python-dotenv`: 1.0.1
16
16
 
17
- Supports Python 3.8 to 3.11
17
+ Supports Python 3.9 to 3.13
18
18
 
19
19
  ## Usage
20
20
  ```python
@@ -23,12 +23,12 @@ import borgapi
23
23
  api = borgapi.BorgAPI(defaults={}, options={})
24
24
 
25
25
  # Initalize new repository
26
- api.init("/foo/bar", make_parent_dirs=True)
26
+ api.init("foo/bar", make_parent_dirs=True)
27
27
 
28
28
  # Create backup
29
- result = api.create("/foo/bar::backup", "/home", "/mnt/baz", json=True)
29
+ result = api.create("foo/bar::backup", "/home", "/mnt/baz", json=True)
30
30
  print(result['archive']["name"]) # backup
31
- print(result["repository"]["location"]) # /foo/bar
31
+ print(result["repository"]["location"]) # foo/bar
32
32
  ```
33
33
 
34
34
  ### BorgAPI Init arguments
@@ -37,7 +37,8 @@ class BorgAPI(
37
37
  defaults: dict = None,
38
38
  options: dict = None,
39
39
  log_level: str = "warning",
40
- log_json: bool = False
40
+ log_json: bool = False,
41
+ environ: dict = None,
41
42
  )
42
43
  ```
43
44
  * __defaults__: dictionary that has command names as keys and value that is a dict of
@@ -71,12 +72,35 @@ class BorgAPI(
71
72
  level as and keyword argument
72
73
  * __log_json__: log lines written by logger are formatted as json lines, passed into the
73
74
  logging setup
75
+ * __environ__: dictionary that contains environmental variables that should be set before running
76
+ any commands. Useful for setting the passphrase or passcommand for the repository or other
77
+ settings like that. See [Environment Variables](#Setting-Environment-Variables) section for
78
+ how to set environmental variables after initalization or what the defaults are.
79
+ ```python
80
+ {
81
+ "BORG_CHECK_I_KNOW_WHAT_I_AM_DOING": "YES",
82
+ "BORG_PASSCOMMAND": "cat ~/.borg/password",
83
+ }
84
+ ```
74
85
 
75
86
  ### Setting Environment Variables
76
87
  You are able to manage the environment variables used by borg to be able to use different settings
77
88
  for different repositories.
78
89
 
79
- There are 3 ways you can set the variables:
90
+ When initialzing the `BorgAPI` object, you can include a dictionary with the `environ` argument.
91
+
92
+ The following are the defaults that BorgAPI will always load so that user input does not hold up
93
+ the app from progressing.
94
+ ```ini
95
+ BORG_EXIT_CODES=modern,
96
+ BORG_PASSPHRASE="",
97
+ BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=no,
98
+ BORG_RELOCATED_REPO_ACCESS_IS_OK=no,
99
+ BORG_CHECK_I_KNOW_WHAT_I_AM_DOING=NO,
100
+ BORG_DELETE_I_KNOW_WHAT_I_AM_DOING=NO,
101
+ ```
102
+
103
+ There are 3 ways you can set the variables after initialization:
80
104
  1. `filename`: Path to a file that contains the variables and their values. See the
81
105
  [python-dotenv README](https://github.com/theskumar/python-dotenv/blob/master/README.md#file-format)
82
106
  for more information.
@@ -99,14 +123,6 @@ will be used, which is searching for a ".env" file somewhere above in the curren
99
123
  [Environment Variables](https://borgbackup.readthedocs.io/en/stable/usage/general.html#environment-variables)
100
124
  used by `borgbackup`.
101
125
 
102
- #### IMPORTANT
103
- For commands that borg requires a confirmation on if no environment variable is given, the api will
104
- become stuck as it waits for a `yes` or `no` answer.
105
- * BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK
106
- * BORG_RELOCATED_REPO_ACCESS_IS_OK
107
- * BORG_CHECK_I_KNOW_WHAT_I_AM_DOING
108
- * BORG_DELETE_I_KNOW_WHAT_I_AM_DOING
109
-
110
126
  ### Removing Environment Variables
111
127
  If you want to unset a variable so it doesn't get used for another command you can use the
112
128
  `unset_environ` method. It'll remove any variables passed in from the current environment.
@@ -133,7 +149,7 @@ So the `--storage-quota` argument in `init` gets turned into the keyword argumen
133
149
 
134
150
  ```python
135
151
  api.init(
136
- repository="/foor/bar",
152
+ repository="foor/bar",
137
153
  encryption="repokey",
138
154
  append_only=True,
139
155
  storage_quota="5G",
@@ -150,9 +166,9 @@ diff_args = {
150
166
  }
151
167
 
152
168
  api.diff(
153
- "/foo/bar::tuesday",
169
+ "foo/bar::tuesday",
154
170
  "friday",
155
- "/foo/bar",
171
+ "foo/bar",
156
172
  "/baz",
157
173
  **diff_args,
158
174
  )
@@ -172,20 +188,18 @@ api.diff(
172
188
  * info
173
189
  * mount
174
190
  * umount
175
- * key_change_passphrase (key change-passphrase)
176
- * key_export (key export)
177
- * key_import (key import)
191
+ * key change-passphrase (key_change_passphrase)
192
+ * key export (key_export)
193
+ * key import (key_import)
178
194
  * upgrade
179
- * export_tar
195
+ * recreate
196
+ * immport-tar (immport_tar)
197
+ * export-tar (export_tar)
180
198
  * serve
181
199
  * config
182
- * with-lock
183
- * break-lock
184
- * benchmark crud
185
-
186
- ### Unavailable Borg Commands
187
- * recreate
188
- * Since this is an experimental feature there are no current plans to implament this.
200
+ * with-lock (with_lock)
201
+ * break-lock (break_lock)
202
+ * benchmark crud (benchmark_crud)
189
203
 
190
204
  ### Command Quirks
191
205
  Things that were changed from the way the default borg commands work to make things a bit
@@ -210,7 +224,8 @@ which outputs the stats info as a json object, it gets written to stdout.
210
224
 
211
225
  If either `json` or `log_json` is set, it'll try to convert the tuple output to json.
212
226
  If it is unable and there is output that is captured it'll return the plaintext value.
213
- If no output is captured, it returns `None`.
227
+ If no output is captured, it returns `None` if expecting a string or `{}` (an empty
228
+ dictionary) if expection some kind of JSON output.
214
229
 
215
230
  If multiple outputs are requested at the same time (like `--stats` and `--list`) the command
216
231
  will return a dictionary with aptly named keys (`--list` key is "list"). If only one output
@@ -242,6 +257,12 @@ Commands not listed return no output (None)
242
257
  - info: `--info`
243
258
  - info
244
259
  - always returns bare value
260
+ - recreate:
261
+ - list: `--list`, `--log-json`
262
+ - stats: `--stats`
263
+ - import tar
264
+ - list: `--list`
265
+ - stats: `--stats`, `--json`
245
266
  - export tar
246
267
  - list: `--list`, `--log-json`
247
268
  - tar: filename == "-"
@@ -252,7 +273,7 @@ Commands not listed return no output (None)
252
273
  - always returns bare value
253
274
 
254
275
  ## Roadmap
255
- - Start work on Borg's beta branch chagnes and keeping up with those
276
+ - Start work on Borg's beta branch again and keeping up with those
256
277
 
257
278
  ## Links
258
279
  * [PyPi Project](https://pypi.org/project/borgapi)
@@ -0,0 +1,45 @@
1
+ """Interface for BorgBackup."""
2
+
3
+ __all__ = [
4
+ "BorgAPI",
5
+ "BorgAPIAsync",
6
+ "CommonOptions",
7
+ "ExclusionOptions",
8
+ "ExclusionInput",
9
+ "ExclusionOutput",
10
+ "FilesystemOptions",
11
+ "ArchiveOptions",
12
+ "ArchiveInput",
13
+ "ArchivePattern",
14
+ "ArchiveOutput",
15
+ "CommandOptions",
16
+ "Json",
17
+ "Output",
18
+ "Options",
19
+ "OutputOptions",
20
+ "ListStringIO",
21
+ "PersistantHandler",
22
+ "BorgLogCapture",
23
+ "OutputCapture",
24
+ ]
25
+
26
+ from .borgapi import BorgAPI as BorgAPI
27
+ from .borgapi import BorgAPIAsync as BorgAPIAsync
28
+ from .capture import BorgLogCapture as BorgLogCapture
29
+ from .capture import ListStringIO as ListStringIO
30
+ from .capture import OutputCapture as OutputCapture
31
+ from .capture import OutputOptions as OutputOptions
32
+ from .capture import PersistantHandler as PersistantHandler
33
+ from .helpers import Json as Json
34
+ from .helpers import Options as Options
35
+ from .helpers import Output as Output
36
+ from .options import ArchiveInput as ArchiveInput
37
+ from .options import ArchiveOptions as ArchiveOptions
38
+ from .options import ArchiveOutput as ArchiveOutput
39
+ from .options import ArchivePattern as ArchivePattern
40
+ from .options import CommandOptions as CommandOptions
41
+ from .options import CommonOptions as CommonOptions
42
+ from .options import ExclusionInput as ExclusionInput
43
+ from .options import ExclusionOptions as ExclusionOptions
44
+ from .options import ExclusionOutput as ExclusionOutput
45
+ from .options import FilesystemOptions as FilesystemOptions