]> git.frykholm.com Git - butterbackup.git/commitdiff
Merge branch 'master' of https://github.com/mikaelfrykholm/butterbackup
authorMikael Frykholm <mikael@backup.codemill.se>
Mon, 23 May 2016 17:49:07 +0000 (19:49 +0200)
committerMikael Frykholm <mikael@backup.codemill.se>
Mon, 23 May 2016 17:49:07 +0000 (19:49 +0200)
1  2 
butterbackup.py

diff --combined butterbackup.py
index 99cf3c70ace4e298e815f88abd558f91a86ae997,a1086b993c0db1a4df80fb23d2e8f3449ce8f99f..26822276a29d6449bb03069493c3be4d85ec498e
@@@ -34,8 -34,10 +34,10 @@@ class Host()
              print(command + excludes + " root@%s:/ "%(self.name) + self.subvol_dir)
              check_call(shlex.split(command + excludes + " root@%s:/ "%(self.name) + self.subvol_dir))
          except CalledProcessError as ex:
-             if ex.returncode not in (12, 30):
-                 print("Rsync did not transfer anything from %s, skipping snapshot."%self.name)
+             if ex.returncode in (24,):
+                 pass
+             else:
+                 print("Rsync error from %s, skipping snapshot. Rsync exit value=%s"%(self.name, ex.returncode))
                  return()
          todays_date = datetime.datetime.now().date().strftime("%F")
          if os.path.exists(os.path.join(self.host_dir, todays_date)):
@@@ -71,22 -73,16 +73,22 @@@ class BackupRunner()
              print("No config found", self.config_dir)
              sys-exit(-1)
  
 -    def run(self):
 -        self.hosts = os.listdir(self.config_dir)
 +    def run(self, hostlist=None):
 +        self.hosts = hostlist or os.listdir(self.config_dir)
  
          for host in self.hosts:
              if host == 'default.cfg':
                  continue
              try:
 +                configfile = os.path.join(self.config_dir, host)
 +
 +                if not os.path.exists(configfile):
 +                    # Trigger logging in the except clause
 +                    raise BaseException()
 +
                  config = configparser.ConfigParser(strict=False)
                  config.read_file(open(os.path.join(self.config_dir, 'default.cfg'),'r'))
 -                config.read(os.path.join(self.config_dir, host))
 +                config.read(configfile)
              except BaseException as ex:
                  print("Config error for %s. Skipping host."%host)
                  continue
@@@ -99,9 -95,5 +101,9 @@@ if __name__ == "__main__"
          print("You need to be root. Otherwise all permissions will be lost.")
          sys.exit(-1)
      br = BackupRunner("/etc/butterbackup")
 -    br.run()
 +
 +    hostlist = sys.argv[1:]
 +    br.run(hostlist=hostlist)
 +
      sys.exit(0)
 +