[target:$] intervals -> [target:$:intervals]
authorTero Marttila <terom@paivola.fi>
Wed, 15 Feb 2012 14:15:38 +0200
changeset 16 d4b9954273a1
parent 15 61f6d0ca0432
child 17 b88653920e7a
[target:$] intervals -> [target:$:intervals]
ignore.list
rsync-snapshot.conf
scripts/pvlbackup-rsync-snapshot
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ignore.list	Wed Feb 15 14:15:38 2012 +0200
@@ -0,0 +1,2 @@
+/lost+found/
+
--- a/rsync-snapshot.conf	Wed Feb 15 13:58:35 2012 +0200
+++ b/rsync-snapshot.conf	Wed Feb 15 14:15:38 2012 +0200
@@ -34,10 +34,11 @@
 ## Targets
 [targets:test]
 path    = ./test
-enable  = true
 source  = /srv/lvm-test/
 
-intervals       = recent day
+[targets:test:intervals]
+recent  = 4
+day     = 7
 
 [targets:test:rsync_options]
 exclude-from    = ignore.list
--- a/scripts/pvlbackup-rsync-snapshot	Wed Feb 15 13:58:35 2012 +0200
+++ b/scripts/pvlbackup-rsync-snapshot	Wed Feb 15 14:15:38 2012 +0200
@@ -245,6 +245,21 @@
             keep    = config_int('keep', keep),
         )
 
+    @classmethod
+    def from_target_config (cls, name, base, arg) :
+        if isinstance(arg, dict) :
+            # full instance
+            return cls(name,
+                format  = arg.get('format', base.format if base else None),
+                keep    = arg.get('keep', base.keep if base else None),
+            )
+        else :
+            # partial instance with keep
+            return cls(name,
+                format  = base.format,
+                keep    = config_int('keep', arg),
+            )
+
     def __init__ (self, name, format, keep) :
         self.name = name
         self.format = format
@@ -265,10 +280,10 @@
         path            = False,
         source          = None,
         enable          = 'no',
-        intervals       = None,
         exclude_from    = None,
 
         # subsections
+        intervals       = None,
         rsync_options   = None,
     ) :
         if not source :
@@ -282,7 +297,12 @@
             _rsync_options.update(rsync_options)
 
         # lookup intervals
-        _intervals = [options.intervals[name] for name in config_list('intervals', intervals)]
+        _intervals = [
+            (
+                # lookup base from options.intervals
+                Interval.from_target_config(name, options.intervals.get(name), arg)
+            ) for name, arg in intervals.iteritems()
+        ]
 
         return cls(name, 
             path            = path if path else name,