/[rdiff-backup]/rdiff-backup/rdiff_backup/Main.py
ViewVC logotype

Diff of /rdiff-backup/rdiff_backup/Main.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.89.2.2 by bescoto, Wed Nov 2 06:28:35 2005 UTC revision 1.89.2.3 by bescoto, Thu Nov 24 05:02:18 2005 UTC
# Line 757  def RemoveOlderThan(rootrp): Line 757  def RemoveOlderThan(rootrp):
757          """Remove all increment files older than a certain time"""          """Remove all increment files older than a certain time"""
758          rootrp = require_root_set(rootrp)          rootrp = require_root_set(rootrp)
759          rot_require_rbdir_base(rootrp)          rot_require_rbdir_base(rootrp)
760          try: time = Time.genstrtotime(remove_older_than_string)  
761            time = rot_check_time(remove_older_than_string)
762            if time is None: return
763            Log("Actual remove older than time: %s" % (time,), 6)
764            manage.delete_earlier_than(Globals.rbdir, time)
765    
766    def rot_check_time(time_string):
767            """Check remove older than time_string, return time in seconds"""
768            try: time = Time.genstrtotime(time_string)
769          except Time.TimeException, exc: Log.FatalError(str(exc))          except Time.TimeException, exc: Log.FatalError(str(exc))
         timep = Time.timetopretty(time)  
         Log("Deleting increment(s) before %s" % timep, 4)  
770    
771          times_in_secs = [inc.getinctime() for inc in          times_in_secs = [inc.getinctime() for inc in
772                    restore.get_inclist(Globals.rbdir.append_path("increments"))]                    restore.get_inclist(Globals.rbdir.append_path("increments"))]
773          times_in_secs = filter(lambda t: t < time, times_in_secs)          times_in_secs = filter(lambda t: t < time, times_in_secs)
774          if not times_in_secs:          if not times_in_secs:
775                  Log.FatalError("No increments older than %s found, exiting."                  Log("No increments older than %s found, exiting." %
776                                             % (timep,), 1, errlevel = 0)                          (Time.timetopretty(time),), 3)
777                    return None
778    
779          times_in_secs.sort()          times_in_secs.sort()
780          inc_pretty_time = "\n".join(map(Time.timetopretty, times_in_secs))          inc_pretty_time = "\n".join(map(Time.timetopretty, times_in_secs))
# Line 775  def RemoveOlderThan(rootrp): Line 782  def RemoveOlderThan(rootrp):
782                  Log.FatalError("Found %d relevant increments, dated:\n%s"                  Log.FatalError("Found %d relevant increments, dated:\n%s"
783                          "\nIf you want to delete multiple increments in this way, "                          "\nIf you want to delete multiple increments in this way, "
784                          "use the --force." % (len(times_in_secs), inc_pretty_time))                          "use the --force." % (len(times_in_secs), inc_pretty_time))
   
785          if len(times_in_secs) == 1:          if len(times_in_secs) == 1:
786                  Log("Deleting increment at time:\n" + inc_pretty_time, 3)                  Log("Deleting increment at time:\n" + inc_pretty_time, 3)
787          else: Log("Deleting increments at times:\n" + inc_pretty_time, 3)          else: Log("Deleting increments at times:\n" + inc_pretty_time, 3)
788          manage.delete_earlier_than(Globals.rbdir, time)          return times_in_secs[-1]+1 # make sure we don't delete current increment
789    
790  def rot_require_rbdir_base(rootrp):  def rot_require_rbdir_base(rootrp):
791          """Make sure pointing to base of rdiff-backup dir"""          """Make sure pointing to base of rdiff-backup dir"""
792          if restore_index != ():          if restore_index != ():
793                  Log.FatalError("Increments for directory %s cannot be removed separately.\n"                  Log.FatalError("Increments for directory %s cannot be removed "
794                                             "Instead run on entire directory %s." %                                             "separately.\nInstead run on entire directory %s." %
795                                             (rootrp.path, restore_root.path))                                             (rootrp.path, restore_root.path))
796    
797    

Legend:
Removed from v.1.89.2.2  
changed lines
  Added in v.1.89.2.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26