瀏覽代碼

Merge pull request #2197 from enkore/f/info-limits

info: show utilization of maximum archive size
enkore 8 年之前
父節點
當前提交
e3a8ccdf3b
共有 4 個文件被更改,包括 14 次插入4 次删除
  1. 5 2
      src/borg/archive.py
  2. 1 0
      src/borg/archiver.py
  3. 4 0
      src/borg/constants.py
  4. 4 2
      src/borg/repository.py

+ 5 - 2
src/borg/archive.py

@@ -350,10 +350,13 @@ Archive fingerprint: {0.fpr}
 Time (start): {start}
 Time (end):   {end}
 Duration: {0.duration}
-Number of files: {0.stats.nfiles}'''.format(
+Number of files: {0.stats.nfiles}
+Utilization of max. archive size: {csize_max:.0%}
+'''.format(
             self,
             start=format_time(to_localtime(self.start.replace(tzinfo=timezone.utc))),
-            end=format_time(to_localtime(self.end.replace(tzinfo=timezone.utc))))
+            end=format_time(to_localtime(self.end.replace(tzinfo=timezone.utc))),
+            csize_max=self.cache.chunks[self.id].csize / MAX_DATA_SIZE)
 
     def __repr__(self):
         return 'Archive(%r)' % self.name

+ 1 - 0
src/borg/archiver.py

@@ -987,6 +987,7 @@ class Archiver:
             print('Duration: %s' % archive.duration_from_meta)
             print('Number of files: %d' % stats.nfiles)
             print('Command line: %s' % format_cmdline(archive.metadata.cmdline))
+            print('Utilization of max. archive size: %d%%' % (100 * cache.chunks[archive.id].csize / MAX_DATA_SIZE))
             print(DASHES)
             print(STATS_HEADER)
             print(str(stats))

+ 4 - 0
src/borg/constants.py

@@ -27,6 +27,10 @@ CACHE_TAG_CONTENTS = b'Signature: 8a477f597d28d172789f06886806bc55'
 # bytes. That's why it's 500 MiB instead of 512 MiB.
 DEFAULT_MAX_SEGMENT_SIZE = 500 * 1024 * 1024
 
+# 20 MiB minus 41 bytes for a Repository header (because the "size" field in the Repository includes
+# the header, and the total size was set to 20 MiB).
+MAX_DATA_SIZE = 20971479
+
 # A few hundred files per directory to go easy on filesystems which don't like too many files per dir (NTFS)
 DEFAULT_SEGMENTS_PER_DIR = 500
 

+ 4 - 2
src/borg/repository.py

@@ -26,7 +26,6 @@ from .crc32 import crc32
 
 logger = create_logger(__name__)
 
-MAX_OBJECT_SIZE = 20 * 1024 * 1024
 MAGIC = b'BORG_SEG'
 MAGIC_LEN = len(MAGIC)
 TAG_PUT = 0
@@ -1204,4 +1203,7 @@ class LoggedIO:
         return self.segment - 1  # close_segment() increments it
 
 
-MAX_DATA_SIZE = MAX_OBJECT_SIZE - LoggedIO.put_header_fmt.size
+# MAX_OBJECT_SIZE = <20 MiB (MAX_DATA_SIZE) + 41 bytes for a Repository PUT header, which consists of
+# a 1 byte tag ID, 4 byte CRC, 4 byte size and 32 bytes for the ID.
+MAX_OBJECT_SIZE = MAX_DATA_SIZE + LoggedIO.put_header_fmt.size
+assert MAX_OBJECT_SIZE == 20971520 == 20 * 1024 * 1024