コード例 #1
0
ファイル: list_.py プロジェクト: detrax/rdiff-backup
    def _list_increments_sizes(self):
        """
        Print out a summary of the increments with their size and
        cumulative size
        """
        triples = self.repo.get_increments_sizes()

        if self.values.parsable_output:
            print(
                yaml.safe_dump(triples, explicit_start=True,
                               explicit_end=True))
        else:
            stat_obj = statistics.StatsObj()  # used for byte summary string

            print("{: ^24} {: ^17} {: ^17}".format("Time", "Size",
                                                   "Cumulative size"))
            print("{:-^24} {:-^17} {:-^17}".format("", "", ""))
            # print the normal increments then the mirror
            for triple in triples[:-1]:
                print("{: <24} {: >17} {: >17}".format(
                    Time.timetopretty(triple["time"]),
                    stat_obj.get_byte_summary_string(triple["size"]),
                    stat_obj.get_byte_summary_string(triple["total_size"])))
            print("{: <24} {: >17} {: >17}  (current mirror)".format(
                Time.timetopretty(triples[-1]["time"]),
                stat_obj.get_byte_summary_string(triples[-1]["size"]),
                stat_obj.get_byte_summary_string(triples[-1]["total_size"])))
コード例 #2
0
ファイル: timetest.py プロジェクト: rdiff-backup/rdiff-backup
 def testPrettyTimes(self):
     """Convert seconds to pretty and back"""
     now = int(time.time())
     for i in [1, 200000, now]:
         self.assertEqual(Time.prettytotime(Time.timetopretty(i)), i)
     self.assertIsNone(Time.prettytotime("now"))
     self.assertIsNone(Time.prettytotime("12314"))
コード例 #3
0
 def testPrettyTimes(self):
     """Convert seconds to pretty and back"""
     now = int(time.time())
     for i in [1, 200000, now]:
         assert Time.prettytotime(Time.timetopretty(i)) == i, i
     assert Time.prettytotime("now") is None
     assert Time.prettytotime("12314") is None
コード例 #4
0
ファイル: timetest.py プロジェクト: ObiWahn/rdiff-backup
	def testPrettyTimes(self):
		"""Convert seconds to pretty and back"""
		now = int(time.time())
		for i in [1, 200000, now]:
			assert Time.prettytotime(Time.timetopretty(i)) == i, i
		assert Time.prettytotime("now") is None
		assert Time.prettytotime("12314") is None
コード例 #5
0
 def _get_timestats_string(self):
     """Return portion of statistics string dealing with time"""
     timelist = []
     if self.StartTime is not None:
         timelist.append(
             "StartTime %.2f (%s)\n" % (self.StartTime,
                                        Time.timetopretty(self.StartTime)))
     if self.EndTime is not None:
         timelist.append("EndTime %.2f (%s)\n" %
                         (self.EndTime, Time.timetopretty(self.EndTime)))
     if self.ElapsedTime or (self.StartTime is not None
                             and self.EndTime is not None):
         if self.ElapsedTime is None:
             self.ElapsedTime = self.EndTime - self.StartTime
         timelist.append(
             "ElapsedTime %.2f (%s)\n" %
             (self.ElapsedTime, Time.inttopretty(self.ElapsedTime)))
     return "".join(timelist)
コード例 #6
0
ファイル: regress.py プロジェクト: rdiff-backup/rdiff-backup
def _yield_metadata():
    """Iterate rorps from metadata file, if any are available"""
    meta_manager = meta_mgr.get_meta_manager(True)
    metadata_iter = meta_manager.get_metas_at_time(regress_time)
    if metadata_iter:
        return metadata_iter
    log.Log.FatalError("No metadata for time {pt} ({rt}) found, "
                       "cannot regress".format(
                           pt=Time.timetopretty(regress_time), rt=regress_time))
コード例 #7
0
ファイル: list_.py プロジェクト: rdiff-backup/rdiff-backup
 def _list_increments(self):
     """
     Print out a summary of the increments and their times
     """
     incs = self.repo.get_increments()
     if self.values.parsable_output:
         if Globals.get_api_version() < 201:
             for inc in incs:
                 print("{ti} {it}".format(ti=inc["time"], it=inc["type"]))
         else:
             print(yaml.safe_dump(incs,
                                  explicit_start=True, explicit_end=True))
     else:
         print("Found {ni} increments:".format(ni=len(incs) - 1))
         for inc in incs[:-1]:
             print("    {ib}   {ti}".format(
                 ib=inc["base"], ti=Time.timetopretty(inc["time"])))
         print("Current mirror: {ti}".format(
             ti=Time.timetopretty(incs[-1]["time"])))  # time of the mirror
コード例 #8
0
    def _get_parsed_time(self, time_string):
        """
        Check remove older than time_string, return time in seconds

        Return None if the time string can't be interpreted as such, or
        if more than one increment would be removed, without the force option,
        or if no increment would be removed.
        """
        action_time = super()._get_parsed_time(time_string)
        if action_time is None:
            return None

        times_in_secs = [
            inc.getinctime()
            for inc in restore.get_inclist(self.source.incs_dir)
        ]
        times_in_secs = [t for t in times_in_secs if t < action_time]
        if not times_in_secs:
            self.log(
                "No increments older than {atim} found, exiting.".format(
                    atim=Time.timetopretty(action_time)), self.log.NOTE)
            return None

        times_in_secs.sort()
        pretty_times = "\n".join(map(Time.timetopretty, times_in_secs))
        if len(times_in_secs) > 1:
            if not self.values.force:
                self.log(
                    "Found {lent} relevant increments, dated:\n{ptim}\n"
                    "If you want to delete multiple increments in this way, "
                    "use the --force option.".format(lent=len(times_in_secs),
                                                     ptim=pretty_times),
                    self.log.ERROR)
                return None
            else:
                self.log(
                    "Deleting increments at times:\n{ptim}".format(
                        ptim=pretty_times), self.log.NOTE)
        else:
            self.log(
                "Deleting increment at time:\n{ptim}".format(
                    ptim=pretty_times), self.log.NOTE)
        # make sure we don't delete current increment
        return times_in_secs[-1] + 1
コード例 #9
0
ファイル: regress.py プロジェクト: rdiff-backup/rdiff-backup
def _set_regress_time():
    """Set global regress_time to previous successful backup

    If there are two current_mirror increments, then the last one
    corresponds to a backup session that failed.

    """
    global regress_time, unsuccessful_backup_time
    meta_manager = meta_mgr.get_meta_manager(True)
    curmir_incs = meta_manager.sorted_prefix_inclist(b'current_mirror')
    assert len(curmir_incs) == 2, (
        "Found {ilen} current_mirror flags, expected 2".format(
            ilen=len(curmir_incs)))
    mirror_rp_to_delete = curmir_incs[0]
    regress_time = curmir_incs[1].getinctime()
    unsuccessful_backup_time = mirror_rp_to_delete.getinctime()
    log.Log("Regressing to date/time {dt}".format(
        dt=Time.timetopretty(regress_time)), log.NOTE)
    return meta_manager, mirror_rp_to_delete