Fri, 19 Jan 2018 10:41:01 +0000
basic config processing
1
4cdc9c1f6b28
basic scheduler structure draft, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
1 | # |
4cdc9c1f6b28
basic scheduler structure draft, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
2 | # Borgend Backup instance |
4cdc9c1f6b28
basic scheduler structure draft, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
3 | # |
4cdc9c1f6b28
basic scheduler structure draft, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
4 | |
2 | 5 | import config |
6 | from instance import BorgInstance | |
7 | ||
1
4cdc9c1f6b28
basic scheduler structure draft, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
8 | class Backup: |
4cdc9c1f6b28
basic scheduler structure draft, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
9 | |
2 | 10 | def __decode_config(self, cfg): |
11 | loc0='backup target %d' % self.identifier | |
12 | ||
13 | self.name=config.check_string(cfg, 'name', 'Name', loc0) | |
14 | ||
15 | self.loc='backup target "%s"' % self.name | |
16 | ||
17 | self.repository=config.check_string(cfg, 'repository', | |
18 | 'Target repository', self.loc) | |
19 | ||
20 | self.archive_template=config.check_string(cfg, 'archive_template', | |
21 | 'Archive template', self.loc) | |
22 | ||
23 | self.backup_interval=config.check_nonneg_int(cfg, 'backup_interval', | |
24 | 'Backup interval', self.loc, | |
25 | config.defaults['backup_interval']) | |
26 | ||
27 | self.retry_interval=config.check_nonneg_int(cfg, 'retry_interval', | |
28 | 'Retry interval', self.loc, | |
29 | config.defaults['retry_interval']) | |
30 | ||
31 | self.paths=config.check_nonempty_list_of_strings(cfg, 'paths', 'Paths', self.loc) | |
32 | ||
33 | self.borg_parameters=config.check_list_of_dicts(cfg, 'borg_parameters', | |
34 | 'Borg parameters', self.loc, | |
35 | default=[]) | |
36 | ||
37 | ||
38 | def __init__(self, identifier, cfg): | |
39 | self.identifier=identifier | |
40 | ||
41 | self.__decode_config(cfg) | |
42 | ||
43 | ||
1
4cdc9c1f6b28
basic scheduler structure draft, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
44 | self.config=config |
4cdc9c1f6b28
basic scheduler structure draft, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
45 | self.lastrun=None |
2 | 46 | self.current_instance=None |
47 | ||
48 | def create(self): | |
49 | if self.current_instance is not None: | |
50 | raise AssertionError('%s running: cannot launch' % self.loc) | |
51 | ||
52 | archive="%s::%s" % (self.repository, self.archive_template) | |
53 | ||
54 | inst=BorgInstance(self.identifier, 'create', self.borg_parameters, | |
55 | archive, self.paths) | |
56 | print(inst.construct_cmdline()) | |
1
4cdc9c1f6b28
basic scheduler structure draft, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
57 | |
4cdc9c1f6b28
basic scheduler structure draft, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
58 | |
4cdc9c1f6b28
basic scheduler structure draft, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
59 |