backupchan-cli 0.2.2__tar.gz → 0.3.0__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.
- {backupchan_cli-0.2.2 → backupchan_cli-0.3.0}/CHANGELOG.md +4 -0
- {backupchan_cli-0.2.2/backupchan_cli.egg-info → backupchan_cli-0.3.0}/PKG-INFO +2 -1
- {backupchan_cli-0.2.2 → backupchan_cli-0.3.0}/backupchan_cli/commands/backup.py +4 -4
- {backupchan_cli-0.2.2 → backupchan_cli-0.3.0}/backupchan_cli/commands/log.py +1 -1
- backupchan_cli-0.3.0/backupchan_cli/commands/preset.py +95 -0
- {backupchan_cli-0.2.2 → backupchan_cli-0.3.0}/backupchan_cli/commands/recyclebin.py +2 -2
- {backupchan_cli-0.2.2 → backupchan_cli-0.3.0}/backupchan_cli/commands/stats.py +1 -1
- {backupchan_cli-0.2.2 → backupchan_cli-0.3.0}/backupchan_cli/commands/target.py +6 -7
- {backupchan_cli-0.2.2 → backupchan_cli-0.3.0}/backupchan_cli/main.py +15 -2
- {backupchan_cli-0.2.2 → backupchan_cli-0.3.0/backupchan_cli.egg-info}/PKG-INFO +2 -1
- {backupchan_cli-0.2.2 → backupchan_cli-0.3.0}/backupchan_cli.egg-info/SOURCES.txt +1 -0
- {backupchan_cli-0.2.2 → backupchan_cli-0.3.0}/backupchan_cli.egg-info/requires.txt +1 -0
- {backupchan_cli-0.2.2 → backupchan_cli-0.3.0}/pyproject.toml +3 -2
- {backupchan_cli-0.2.2 → backupchan_cli-0.3.0}/.gitignore +0 -0
- {backupchan_cli-0.2.2 → backupchan_cli-0.3.0}/LICENSE +0 -0
- {backupchan_cli-0.2.2 → backupchan_cli-0.3.0}/README.md +0 -0
- {backupchan_cli-0.2.2 → backupchan_cli-0.3.0}/backupchan_cli/__init__.py +0 -0
- {backupchan_cli-0.2.2 → backupchan_cli-0.3.0}/backupchan_cli/commands/config.py +0 -0
- {backupchan_cli-0.2.2 → backupchan_cli-0.3.0}/backupchan_cli/utility.py +0 -0
- {backupchan_cli-0.2.2 → backupchan_cli-0.3.0}/backupchan_cli.egg-info/dependency_links.txt +0 -0
- {backupchan_cli-0.2.2 → backupchan_cli-0.3.0}/backupchan_cli.egg-info/entry_points.txt +0 -0
- {backupchan_cli-0.2.2 → backupchan_cli-0.3.0}/backupchan_cli.egg-info/top_level.txt +0 -0
- {backupchan_cli-0.2.2 → backupchan_cli-0.3.0}/cli.py +0 -0
- {backupchan_cli-0.2.2 → backupchan_cli-0.3.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: backupchan-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Command-line interface for interacting with Backup-chan.
|
|
5
5
|
Author-email: Moltony <koronavirusnyj@gmail.com>
|
|
6
6
|
License: BSD-3-Clause
|
|
@@ -20,6 +20,7 @@ Description-Content-Type: text/markdown
|
|
|
20
20
|
License-File: LICENSE
|
|
21
21
|
Requires-Dist: backupchan-client-lib>=0.3.0
|
|
22
22
|
Requires-Dist: backupchan-client-config>=0.1.0
|
|
23
|
+
Requires-Dist: backupchan-presets>=0.1.2
|
|
23
24
|
Dynamic: license-file
|
|
24
25
|
|
|
25
26
|
# Backup-chan CLI
|
|
@@ -68,7 +68,7 @@ def setup_subcommands(subparser):
|
|
|
68
68
|
# backupchan backup upload
|
|
69
69
|
#
|
|
70
70
|
|
|
71
|
-
def do_upload(args,
|
|
71
|
+
def do_upload(args, api: API):
|
|
72
72
|
if os.path.isdir(args.filename):
|
|
73
73
|
try:
|
|
74
74
|
api.upload_backup_folder(args.target_id, args.filename, not args.automatic)
|
|
@@ -90,7 +90,7 @@ def do_upload(args, _, api: API):
|
|
|
90
90
|
# backupchan backup delete
|
|
91
91
|
#
|
|
92
92
|
|
|
93
|
-
def do_delete(args,
|
|
93
|
+
def do_delete(args, api: API):
|
|
94
94
|
delete_files = args.delete_files
|
|
95
95
|
|
|
96
96
|
try:
|
|
@@ -108,7 +108,7 @@ def do_delete(args, _, api: API):
|
|
|
108
108
|
# backupchan backup recycle
|
|
109
109
|
#
|
|
110
110
|
|
|
111
|
-
def do_recycle(args,
|
|
111
|
+
def do_recycle(args, api: API):
|
|
112
112
|
try:
|
|
113
113
|
api.recycle_backup(args.id, True)
|
|
114
114
|
except requests.exceptions.ConnectionError:
|
|
@@ -124,7 +124,7 @@ def do_recycle(args, _, api: API):
|
|
|
124
124
|
# backupchan backup restore
|
|
125
125
|
#
|
|
126
126
|
|
|
127
|
-
def do_restore(args,
|
|
127
|
+
def do_restore(args, api: API):
|
|
128
128
|
try:
|
|
129
129
|
api.recycle_backup(args.id, False)
|
|
130
130
|
except requests.exceptions.ConnectionError:
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
from backupchan_cli import utility
|
|
2
|
+
from backupchan import API
|
|
3
|
+
from backupchan_presets import Presets, PresetError
|
|
4
|
+
|
|
5
|
+
#
|
|
6
|
+
#
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
def setup_subcommands(subparser):
|
|
10
|
+
#
|
|
11
|
+
#
|
|
12
|
+
#
|
|
13
|
+
|
|
14
|
+
list_cmd = subparser.add_parser("list", help="List all presets")
|
|
15
|
+
list_cmd.set_defaults(func=do_list)
|
|
16
|
+
|
|
17
|
+
#
|
|
18
|
+
#
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
new_cmd = subparser.add_parser("new", help="Create a new preset")
|
|
22
|
+
new_cmd.add_argument("name", type=str, help="Name of the new preset. Must be unique.")
|
|
23
|
+
new_cmd.add_argument("location", type=str, help="Path to file or directory to back up")
|
|
24
|
+
new_cmd.add_argument("target_id", type=str, help="ID of the target to upload backups to")
|
|
25
|
+
new_cmd.set_defaults(func=do_new)
|
|
26
|
+
|
|
27
|
+
#
|
|
28
|
+
#
|
|
29
|
+
#
|
|
30
|
+
|
|
31
|
+
delete_cmd = subparser.add_parser("delete", help="Delete an existing preset")
|
|
32
|
+
delete_cmd.add_argument("name", type=str, help="Name of the preset to delete")
|
|
33
|
+
delete_cmd.set_defaults(func=do_delete)
|
|
34
|
+
|
|
35
|
+
#
|
|
36
|
+
#
|
|
37
|
+
#
|
|
38
|
+
|
|
39
|
+
upload_cmd = subparser.add_parser("upload", help="Upload a backup according to an existing preset")
|
|
40
|
+
upload_cmd.add_argument("name", type=str, help="Name of the preset to use")
|
|
41
|
+
upload_cmd.add_argument("--automatic", "-a", action="store_true", help="Mark this backup as automatic")
|
|
42
|
+
upload_cmd.set_defaults(func=do_upload)
|
|
43
|
+
|
|
44
|
+
#
|
|
45
|
+
#
|
|
46
|
+
#
|
|
47
|
+
|
|
48
|
+
reset_cmd = subparser.add_parser("reset", help="Delete all existing presets")
|
|
49
|
+
reset_cmd.set_defaults(func=do_reset)
|
|
50
|
+
|
|
51
|
+
#
|
|
52
|
+
# backupchan preset list
|
|
53
|
+
#
|
|
54
|
+
|
|
55
|
+
def do_list(args, presets: Presets, _):
|
|
56
|
+
if len(presets) == 0:
|
|
57
|
+
print("There are no presets.")
|
|
58
|
+
|
|
59
|
+
for preset_name in presets:
|
|
60
|
+
preset = presets[preset_name]
|
|
61
|
+
print(f" | '{preset_name}' - location: '{preset.location}', target: '{preset.target_id}'")
|
|
62
|
+
|
|
63
|
+
#
|
|
64
|
+
# backupchan preset new
|
|
65
|
+
#
|
|
66
|
+
|
|
67
|
+
def do_new(args, presets: Presets, _):
|
|
68
|
+
presets.add(args.name, args.location, args.target_id)
|
|
69
|
+
presets.save()
|
|
70
|
+
print("Preset saved.")
|
|
71
|
+
|
|
72
|
+
#
|
|
73
|
+
# backupchan preset delete
|
|
74
|
+
#
|
|
75
|
+
|
|
76
|
+
def do_delete(args, presets: Presets, _):
|
|
77
|
+
presets.remove(args.name)
|
|
78
|
+
presets.save()
|
|
79
|
+
print("Preset deleted.")
|
|
80
|
+
|
|
81
|
+
#
|
|
82
|
+
# backupchan preset upload
|
|
83
|
+
#
|
|
84
|
+
|
|
85
|
+
def do_upload(args, presets: Presets, api: API):
|
|
86
|
+
presets[args.name].upload(api, not args.automatic)
|
|
87
|
+
print(f"Backup uploaded with preset '{args.name}'.")
|
|
88
|
+
|
|
89
|
+
#
|
|
90
|
+
# backupchan preset reset
|
|
91
|
+
#
|
|
92
|
+
|
|
93
|
+
def do_reset(args, _, __):
|
|
94
|
+
Presets().save()
|
|
95
|
+
print(f"Presets reset.")
|
|
@@ -18,7 +18,7 @@ def setup_subcommands(subparser):
|
|
|
18
18
|
# backupchan recyclebin view
|
|
19
19
|
#
|
|
20
20
|
|
|
21
|
-
def do_view(args,
|
|
21
|
+
def do_view(args, api: API):
|
|
22
22
|
try:
|
|
23
23
|
backups = api.list_recycled_backups()
|
|
24
24
|
except requests.exceptions.ConnectionError:
|
|
@@ -32,7 +32,7 @@ def do_view(args, _, api: API):
|
|
|
32
32
|
# backupchan recyclebin clear
|
|
33
33
|
#
|
|
34
34
|
|
|
35
|
-
def do_clear(args,
|
|
35
|
+
def do_clear(args, api: API):
|
|
36
36
|
try:
|
|
37
37
|
api.clear_recycle_bin(args.delete_files)
|
|
38
38
|
except requests.exceptions.ConnectionError:
|
|
@@ -13,7 +13,7 @@ def setup_subcommands(subparser):
|
|
|
13
13
|
# backupchan stats view
|
|
14
14
|
#
|
|
15
15
|
|
|
16
|
-
def do_view(args,
|
|
16
|
+
def do_view(args, api: API):
|
|
17
17
|
stats = api.view_stats()
|
|
18
18
|
print(f" | Server version: {stats.program_version}")
|
|
19
19
|
print(f" | Total size of all targets: {utility.humanread_file_size(stats.total_target_size)}")
|
|
@@ -126,7 +126,7 @@ def hr_recycle_criteria(target: BackupTarget) -> str:
|
|
|
126
126
|
# backupchan target list
|
|
127
127
|
#
|
|
128
128
|
|
|
129
|
-
def do_list(args,
|
|
129
|
+
def do_list(args, api: API):
|
|
130
130
|
try:
|
|
131
131
|
targets = api.list_targets(args.page)
|
|
132
132
|
except requests.exceptions.ConnectionError:
|
|
@@ -146,8 +146,7 @@ def do_list(args, _, api: API):
|
|
|
146
146
|
# backupchan target view
|
|
147
147
|
#
|
|
148
148
|
|
|
149
|
-
|
|
150
|
-
def do_view(args, _, api: API):
|
|
149
|
+
def do_view(args, api: API):
|
|
151
150
|
try:
|
|
152
151
|
target, backups = api.get_target(args.id)
|
|
153
152
|
except requests.exceptions.ConnectionError:
|
|
@@ -179,7 +178,7 @@ def do_view(args, _, api: API):
|
|
|
179
178
|
# backupchan target new
|
|
180
179
|
#
|
|
181
180
|
|
|
182
|
-
def do_new(args,
|
|
181
|
+
def do_new(args, api: API):
|
|
183
182
|
utility.required_args(args, "name", "type", "recycle_criteria", "location", "name_template")
|
|
184
183
|
|
|
185
184
|
name = args.name
|
|
@@ -210,7 +209,7 @@ def do_new(args, _, api: API):
|
|
|
210
209
|
# backupchan target delete
|
|
211
210
|
#
|
|
212
211
|
|
|
213
|
-
def do_delete(args,
|
|
212
|
+
def do_delete(args, api: API):
|
|
214
213
|
delete_files = args.delete_files
|
|
215
214
|
|
|
216
215
|
try:
|
|
@@ -225,7 +224,7 @@ def do_delete(args, _, api: API):
|
|
|
225
224
|
# backupchan target edit
|
|
226
225
|
#
|
|
227
226
|
|
|
228
|
-
def do_edit(args,
|
|
227
|
+
def do_edit(args, api: API):
|
|
229
228
|
target_id = args.id
|
|
230
229
|
|
|
231
230
|
try:
|
|
@@ -261,7 +260,7 @@ def do_edit(args, _, api: API):
|
|
|
261
260
|
# backupchan target deletebackups
|
|
262
261
|
#
|
|
263
262
|
|
|
264
|
-
def do_delete_backups(args,
|
|
263
|
+
def do_delete_backups(args, api: API):
|
|
265
264
|
delete_files = args.delete_files
|
|
266
265
|
|
|
267
266
|
try:
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
from .commands import config, target, backup, log, recyclebin, stats
|
|
1
|
+
from .commands import config, target, backup, log, recyclebin, stats, preset
|
|
2
2
|
from .utility import failure, NO_CONFIG_MESSAGE
|
|
3
3
|
from backupchan_config import Config, ConfigException
|
|
4
|
+
from backupchan_presets import Presets
|
|
4
5
|
from backupchan import API
|
|
5
6
|
import argparse
|
|
6
7
|
|
|
@@ -32,6 +33,13 @@ def main():
|
|
|
32
33
|
stats_sub = stats_parser.add_subparsers(dest="subcommand", help="View statistics")
|
|
33
34
|
stats.setup_subcommands(stats_sub)
|
|
34
35
|
|
|
36
|
+
preset_parser = subparsers.add_parser("preset")
|
|
37
|
+
preset_sub = preset_parser.add_subparsers(dest="subcommand", help="View, manage and run backup presets")
|
|
38
|
+
preset.setup_subcommands(preset_sub)
|
|
39
|
+
|
|
40
|
+
backup_presets = Presets()
|
|
41
|
+
backup_presets.load()
|
|
42
|
+
|
|
35
43
|
app_config = Config()
|
|
36
44
|
try:
|
|
37
45
|
app_config.read_config()
|
|
@@ -46,7 +54,12 @@ def main():
|
|
|
46
54
|
if args.command != "config" and app_config.is_incomplete():
|
|
47
55
|
failure(NO_CONFIG_MESSAGE)
|
|
48
56
|
|
|
49
|
-
args.
|
|
57
|
+
if args.command == "preset":
|
|
58
|
+
args.func(args, backup_presets, api)
|
|
59
|
+
elif args.command == "config":
|
|
60
|
+
args.func(args, app_config, api)
|
|
61
|
+
else:
|
|
62
|
+
args.func(args, api)
|
|
50
63
|
else:
|
|
51
64
|
parser.print_help()
|
|
52
65
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: backupchan-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Command-line interface for interacting with Backup-chan.
|
|
5
5
|
Author-email: Moltony <koronavirusnyj@gmail.com>
|
|
6
6
|
License: BSD-3-Clause
|
|
@@ -20,6 +20,7 @@ Description-Content-Type: text/markdown
|
|
|
20
20
|
License-File: LICENSE
|
|
21
21
|
Requires-Dist: backupchan-client-lib>=0.3.0
|
|
22
22
|
Requires-Dist: backupchan-client-config>=0.1.0
|
|
23
|
+
Requires-Dist: backupchan-presets>=0.1.2
|
|
23
24
|
Dynamic: license-file
|
|
24
25
|
|
|
25
26
|
# Backup-chan CLI
|
|
@@ -16,6 +16,7 @@ backupchan_cli.egg-info/top_level.txt
|
|
|
16
16
|
backupchan_cli/commands/backup.py
|
|
17
17
|
backupchan_cli/commands/config.py
|
|
18
18
|
backupchan_cli/commands/log.py
|
|
19
|
+
backupchan_cli/commands/preset.py
|
|
19
20
|
backupchan_cli/commands/recyclebin.py
|
|
20
21
|
backupchan_cli/commands/stats.py
|
|
21
22
|
backupchan_cli/commands/target.py
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "backupchan-cli"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.3.0"
|
|
4
4
|
description = "Command-line interface for interacting with Backup-chan."
|
|
5
5
|
authors = [
|
|
6
6
|
{ name = "Moltony", email = "koronavirusnyj@gmail.com" }
|
|
7
7
|
]
|
|
8
8
|
dependencies = [
|
|
9
9
|
"backupchan-client-lib>=0.3.0",
|
|
10
|
-
"backupchan-client-config>=0.1.0"
|
|
10
|
+
"backupchan-client-config>=0.1.0",
|
|
11
|
+
"backupchan-presets>=0.1.2"
|
|
11
12
|
]
|
|
12
13
|
|
|
13
14
|
readme = "README.md"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|