change rsync-snapshot.conf to use [foo/bar] syntax, because
authorTero Marttila <terom@paivola.fi>
Fri, 02 Mar 2012 17:09:44 +0200
changeset 36 6070507e09ce
parent 35 b6c0bdd6d8d4
child 37 9103a9456087
change rsync-snapshot.conf to use [foo/bar] syntax, because
rsync-snapshot.conf
scripts/pvlbackup-rsync-snapshot
--- a/rsync-snapshot.conf	Fri Mar 02 16:59:14 2012 +0200
+++ b/rsync-snapshot.conf	Fri Mar 02 17:09:44 2012 +0200
@@ -11,43 +11,43 @@
 delete              = true
 
 ## Intervals
-[intervals:recent]
+[intervals/recent]
 format  = 
 keep    = 4
 
-[intervals:day]
+[intervals/day]
 format  = %Y-%m-%d
 keep    = 7
 
-[intervals:week]
+[intervals/week]
 format  = %Y-%W
 keep    = 4
 
-[intervals:month]
+[intervals/month]
 format  = %Y-%m
 keep    = 4
 
-[intervals:year]
+[intervals/year]
 format  = %Y
 keep    = 1
 
 ## Targets
-[targets:test]
+[targets/test]
 path    = ./test
 source  = /srv/lvm-test/
 
-[targets:test:intervals]
+[targets/test/intervals]
 recent  = 4
 day     = 7
 
-[targets:test:rsync_options]
+[targets/test/rsync_options]
 exclude-from    = ignore.list
 
-[targets:test-lvm]
+[targets/test-lvm]
 path    = ./test-lvm
 source  = backups_test:lvm:asdf:test
 
-[targets:test-lvm:intervals]
+[targets/test-lvm/intervals]
 recent  = 4
 
 
--- a/scripts/pvlbackup-rsync-snapshot	Fri Mar 02 16:59:14 2012 +0200
+++ b/scripts/pvlbackup-rsync-snapshot	Fri Mar 02 17:09:44 2012 +0200
@@ -21,7 +21,7 @@
 
 log = logging.getLogger()
 
-# command-line options
+# command-line options, global state
 options = None
 
 def parse_options (argv, defaults) :
@@ -146,7 +146,12 @@
         log.debug("section: %s", section_name)
 
         # subsections
-        section_path = section_name.split(':')
+        if ':' in section_name :
+            # legacy!
+            section_path = section_name.split(':')
+        else :
+            # new! shiny!
+            section_path = section_name.split('/')
 
         # lookup section dict from config
         lookup = config
@@ -295,7 +300,7 @@
             try :
                 base = options.intervals[interval]
             except KeyError:
-                raise ConfigError("Unknown interval for [target:{target}]: {interval}".format(target=name, interval=interval))
+                raise ConfigError("Unknown interval for [target/{target}]: {interval}".format(target=name, interval=interval))
 
             # parse
             yield Interval.from_target_config(interval, base, arg)
@@ -312,7 +317,7 @@
         rsync_options   = None,
     ) :
         if not source and source is not False :
-            raise ConfigError("Missing required option: source for [target:{name}]".format(name=name))
+            raise ConfigError("Missing required option: source for [target/{name}]".format(name=name))
 
         # global defaults
         _rsync_options = dict(options.rsync_options)