equal
deleted
inserted
replaced
287 |
287 |
288 [target:...] |
288 [target:...] |
289 """ |
289 """ |
290 |
290 |
291 @classmethod |
291 @classmethod |
|
292 def config_intervals (cls, name, intervals) : |
|
293 for interval, arg in intervals.iteritems() : |
|
294 # lookup base from options.intervals |
|
295 try : |
|
296 base = options.intervals[interval] |
|
297 except KeyError: |
|
298 raise ConfigError("Unknown interval for [target:{target}]: {interval}".format(target=name, interval=interval)) |
|
299 |
|
300 # parse |
|
301 yield Interval.from_target_config(interval, base, arg) |
|
302 |
|
303 @classmethod |
292 def from_config (cls, options, name, |
304 def from_config (cls, options, name, |
293 path = False, |
305 path = False, |
294 source = None, |
306 source = None, |
295 enable = 'no', |
307 enable = 'no', |
296 exclude_from = None, |
308 exclude_from = None, |
311 # parse |
323 # parse |
312 (option, config_bool(option, value, strict=False)) for option, value in rsync_options.iteritems() |
324 (option, config_bool(option, value, strict=False)) for option, value in rsync_options.iteritems() |
313 ]) |
325 ]) |
314 |
326 |
315 # lookup intervals |
327 # lookup intervals |
316 _intervals = [ |
328 _intervals = list(cls.config_intervals(name, intervals)) |
317 ( |
|
318 # lookup base from options.intervals |
|
319 Interval.from_target_config(name, options.intervals.get(name), arg) |
|
320 ) for name, arg in intervals.iteritems() |
|
321 ] |
|
322 |
329 |
323 return cls(name, |
330 return cls(name, |
324 path = path if path else name, |
331 path = path if path else name, |
325 source = source, |
332 source = source, |
326 enable = config_bool('enable', enable), |
333 enable = config_bool('enable', enable), |
441 |
448 |
442 # already there? |
449 # already there? |
443 if os.path.exists(path) : |
450 if os.path.exists(path) : |
444 target = os.readlink(path) |
451 target = os.readlink(path) |
445 |
452 |
446 log.info("%s: Found existing: %s -> %s", interval, name, target) |
453 log.info("%s: Keeping existing: %s -> %s", interval, name, target) |
447 |
454 |
448 else : |
455 else : |
449 # update |
456 # update |
450 target = os.path.join('..', 'snapshots', snapshot_name) |
457 target = os.path.join('..', 'snapshots', snapshot_name) |
451 |
458 |
541 |
548 |
542 if broken : |
549 if broken : |
543 log.warn("Found broken symlinks to snapshots: %s", ' '.join(broken)) |
550 log.warn("Found broken symlinks to snapshots: %s", ' '.join(broken)) |
544 |
551 |
545 if unused : |
552 if unused : |
546 log.info("Clean out unused snapshots: %s", ' '.join(unused)) |
553 log.info("Cleaning out %d unused snapshots:", len(unused)) |
547 |
554 |
548 for name in unused : |
555 for name in unused : |
549 path = os.path.join(snapshots_path, name) |
556 path = os.path.join(snapshots_path, name) |
550 |
557 |
551 log.info("Clean: %s", name) |
558 log.info("Clean: %s", name) |