From 9165f8b2dc31d1d68cc025b90c8b0fb22eed5fc1 Mon Sep 17 00:00:00 2001 From: Rob Weber Date: Tue, 29 Jan 2013 10:38:08 -0600 Subject: [PATCH] added backup rotation --- resources/lib/backup.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/resources/lib/backup.py b/resources/lib/backup.py index 6cbe990..2f01458 100644 --- a/resources/lib/backup.py +++ b/resources/lib/backup.py @@ -151,7 +151,22 @@ class XbmcBackup: self.backupFiles(fileGroup['files'],self.xbmc_vfs,self.remote_vfs) #remove old backups - + total_backups = int(utils.getSetting('backup_rotation')) + if(total_backups > 0): + + dirs,files = self.remote_vfs.listdir(remote_base_path) + if(len(dirs) > total_backups): + #remove backups to equal total wanted + dirs.sort() + remove_num = len(dirs) - total_backups - 1 + self.filesTotal = self.filesTotal + remove_num + 1 + + #update the progress bar if it is available + while(remove_num >= 0 and not self._checkCancel()): + self._updateProgress(utils.getString(30054) + " " + dirs[remove_num]) + utils.log("Removing backup " + dirs[remove_num]) + self.remote_vfs.rmdir(remote_base_path + dirs[remove_num] + "/") + remove_num = remove_num - 1 def backupFiles(self,fileList,source,dest): utils.log("Writing files to: " + dest.root_path)