# HG changeset patch # User Tero Marttila # Date 1330701376 -7200 # Node ID 9103a94560872a115b0e1af8c0c488aa61bfbcd9 # Parent 6070507e09ce945bb3bbe1544e714f51841db220 rsync-snapshot: fail nicer-ly if no intervals are given; deprecate default keep intervals, just don't cleanup old snapshots if no keep is given diff -r 6070507e09ce -r 9103a9456087 rsync-snapshot.conf --- a/rsync-snapshot.conf Fri Mar 02 17:09:44 2012 +0200 +++ b/rsync-snapshot.conf Fri Mar 02 17:16:16 2012 +0200 @@ -13,25 +13,21 @@ ## Intervals [intervals/recent] format = -keep = 4 [intervals/day] format = %Y-%m-%d -keep = 7 [intervals/week] format = %Y-%W -keep = 4 [intervals/month] format = %Y-%m -keep = 4 [intervals/year] format = %Y -keep = 1 ## Targets +# test [targets/test] path = ./test source = /srv/lvm-test/ @@ -39,10 +35,13 @@ [targets/test/intervals] recent = 4 day = 7 +year = [targets/test/rsync_options] exclude-from = ignore.list + +# test-lvm [targets/test-lvm] path = ./test-lvm source = backups_test:lvm:asdf:test diff -r 6070507e09ce -r 9103a9456087 scripts/pvlbackup-rsync-snapshot --- a/scripts/pvlbackup-rsync-snapshot Fri Mar 02 17:09:44 2012 +0200 +++ b/scripts/pvlbackup-rsync-snapshot Fri Mar 02 17:16:16 2012 +0200 @@ -194,7 +194,11 @@ # allow non-boolean values return value -def config_int (name, value) : +def config_int (name, value, default=False) : + if not value and default is not False: + # returning default value if one is given + return default + try : return int(value) @@ -250,7 +254,9 @@ @classmethod def from_config (cls, options, name, format, - keep, + + # deprecated + keep = None, ) : if not format : # magic to use snapshot name @@ -260,7 +266,7 @@ return cls(name, format = _format, - keep = config_int('keep', keep), + keep = config_int('keep', keep, default=None), ) @classmethod @@ -329,6 +335,9 @@ (option, config_bool(option, value, strict=False)) for option, value in rsync_options.iteritems() ]) + if not intervals : + raise ConfigError("Missing required [target/{name}/intervals]".format(name=name)) + # lookup intervals _intervals = list(cls.config_intervals(name, intervals)) @@ -482,6 +491,10 @@ # configured keep = interval.keep + if not keep : + log.info("%s: Zero keep given, not cleaning up anything", interval) + return + # items to clean? items = os.listdir(dir_path)