-
Notifications
You must be signed in to change notification settings - Fork 0
/
thrifty.py
executable file
·35 lines (28 loc) · 1.27 KB
/
thrifty.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import argparse
from thriftybackup import CONFIG_PATH
from thriftybackup.config import Configuration
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--echo', action='store_true',
help="Echo the rclone commands before executing them")
parser.add_argument('--dry-run', action='store_true',
help="Dry-run rclone commands")
subparsers = parser.add_subparsers(dest='command', )#help='')
parser_list = subparsers.add_parser('list', help='list backup snapshots')
parser_list.add_argument('backup', help="The backup configuration for which"
" to list snapshots")
args = parser.parse_args()
match args.command:
case 'list':
config = Configuration(CONFIG_PATH, echo=args.echo,
dry_run=args.dry_run)
if args.backup not in config:
msg = (f"There is no backup named '{args.backup}'. Choose one"
f" from:\n" + '\n'.join(f'- {n}' for n in config))
raise SystemExit(msg)
backup = config[args.backup]
backup.print_snapshot_sizes()
case _:
parser.print_help()
if __name__ == "__main__":
main()