File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
mongodb_consistent_backup Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -59,18 +59,22 @@ def rotate(self):
5959 logging .info ("Rotating backups (max_backups=%i, max_days=%.2f)" % (self .max_backups , self .max_days ))
6060 kept_backups = 1
6161 now = int (time ())
62+ remove_backups = {}
6263 for ts in sorted (self .backups .iterkeys (), reverse = True ):
6364 backup = self .backups [ts ]
65+ name = backup ["name" ].encode ("ascii" , "ignore" )
6466 if self .max_backups == 0 or kept_backups < self .max_backups :
6567 if self .max_secs > 0 and (now - ts ) > self .max_secs :
66- logging .info ("Backup %s exceeds max age %.2f days, removing backup" % (backup ["name" ], self .max_days ))
67- self .remove (ts )
68+ remove_backups [name ] = ts
6869 continue
69- logging .info ("Keeping previous backup %s" % backup [ " name" ] )
70+ logging .debug ("Keeping previous backup %s" % name )
7071 kept_backups += 1
7172 else :
72- logging .info ("Backup %s exceeds max backup count %i, removing backup" % (backup ["name" ], self .max_backups ))
73- self .remove (ts )
73+ remove_backups [name ] = ts
74+ if len (remove_backups ) > 0 :
75+ logging .info ("Backup(s) exceeds max backup count or age, removing: %s" % remove_backups .keys ())
76+ for name in remove_backups :
77+ self .remove (remove_backups [name ])
7478
7579 def symlink (self ):
7680 try :
You can’t perform that action at this time.
0 commit comments