X-Git-Url: https://git.sthu.org/?p=sitarba.git;a=blobdiff_plain;f=sitarba;h=b67925fd27435b8c236de566f5bfc58f175ca8c2;hp=3ff4bfff4754abd7fd37c110f803315cfefb3a8f;hb=766966681b508aa0455fa1c538346fce422256bb;hpb=5d9e2e7e23bf0b5926f1681bc3991632fe0140a7 diff --git a/sitarba b/sitarba index 3ff4bff..b67925f 100755 --- a/sitarba +++ b/sitarba @@ -356,7 +356,7 @@ class BackupManager: return [ d for d in dirs if os.path.isdir(os.path.join(basedir, d)) ] - def listOldBackups(self): + def listExistingBackups(self): """Returns a list of old backups.""" backups = [] @@ -403,7 +403,7 @@ class BackupManager: taropts = [] # Tar is verbose is sitarba is verbose - if LogConf.con.level <= logging.INFO: + if LogConf.con.level <= logging.DEBUG: taropts += ["--verbose"] # Add the since date, if given @@ -463,7 +463,7 @@ class BackupManager: then use mode for given epoch. Use given mode otherwise.""" now = datetime.datetime.now() - oldbackups = self.listOldBackups() + oldbackups = self.listExistingBackups() # Get epoch of backup if epoch == None: @@ -540,14 +540,16 @@ class BackupManager: """Prune old backup files""" allDirs = sorted(self.listAllDirs()) - # Collect all directories not matching backup name + # Collect all directories that are removed removeDirs = [ d for d in allDirs if not Backup.isBackupDir(d) ] - # Get all directories which are kept - backups = self.listOldBackups() - keepdirs = [] + # Get all backups + backups = self.listExistingBackups() + # Group backups by epoch and sort them by age byepoch = { e : list(sorted( [ b for b in backups if b.epoch == e ], \ - key=lambda b : b.date, reverse=True)) for e in self.conf.getRealEpochsSorted() } + key=lambda b : b.date, reverse=True)) \ + for e in self.conf.getRealEpochsSorted() } + # If we have too many backups of a specific epoch --> add them to remove list for e in byepoch: epoch = self.conf.epochs[e] old = byepoch[e][epoch.numkeeps:] @@ -708,7 +710,7 @@ if __name__ == "__main__": man.backup(epoch, mode) if cmd == "list": - for b in sorted(man.listOldBackups(), key=lambda b: b.date): + for b in sorted(man.listExistingBackups(), key=lambda b: b.date): print(b.colAlignedString()) if cmd == "prune":