Skip to content

borg2: list: Display nanosecond precision timestamps #10583

Open

Description

@mburghardt

https://github.com/borgbackup/borg/commit/6f9cb17c80043fb3a32bc8cc77642f9969e1edea provided the possibility to display timestamps in nanosecond precision. However, the feature doesn't seem to be used, e.g. in borg list. I propose a small patch to actually display nanosecond timestamps:

--- /tmp/a/parseformat.py       2026-11-01 17:00:22.573067730 +0100
+++ /tmp/b/parseformat.py       2026-11-01 17:04:15.289401967 +0100
@@ -29,7 +29,7 @@
 from .fs import make_path_safe, slashify
 from .argparsing import Action, ArgumentError, ArgumentTypeError, register_type
 from .msgpack import Timestamp
-from .time import OutputTimestamp, format_time, format_time_ns, safe_timestamp
+from .time import OutputTimestamp, format_time, format_time_ns, safe_timestamp, safe_ns
 from .. import __version__ as borg_version
 from .. import __version_tuple__ as borg_version_tuple
 from ..constants import *  # NOQA
@@ -1355,7 +1355,8 @@
         return hash.hexdigest()
 
     def format_time(self, key, item):
-        return OutputTimestamp(safe_timestamp(item.get(key) or item.mtime))
+        ts = item.get(key) or item.mtime
+        return OutputTimestamp(safe_timestamp(ts), safe_ns(ts)%1_000_000_000)
 
     def format_iso_time(self, key, item):
         return self.format_time(key, item).isoformat()

Activity

  1. ThomasWaldmann commented on Nov 1, 2026

    @ThomasWaldmann
    Member

    Well, this has pros and cons:

    • of course, this is more precise and might be interesting in some cases
    • in many cases, sub second information is not interesting though and just adds bloat

    I am somehow indifferent, could live with both ways.

    So guess this needs more feedback from other users:

    • thumbs up on top post if you want nanosecond output in borg list
    • thumbs down if you don't
  2. added this to the 2.0.0rc1 milestone on Nov 1, 2026
  3. PhrozenByte commented on Nov 1, 2026

    @PhrozenByte
    Contributor

    Regarding borg list specifically: We could populate the timestamps with nanosecond precision but use {mtime:24} in the default --format string (i.e., hide them by default).

    Regarding nanosecond precision in general: IMHO, normal text output is intended for humans, and humans rarely (if ever) care about nanoseconds. Nanoseconds should be included in --json output, though. Also, see my earlier thoughts on this in #9840 (comment)

  4. goebbe commented on Nov 2, 2026

    @goebbe
    Contributor

    Personally, I never missed nanoseconds in borg list for my own usage, with a relative small number of backups.

    What would be the real world use case, where nanoseconds in borg list matter?
    Would this type of precission be useful for real world debugging/ professional usecases?
    To me it seems that log files are a better place for debugging/ precise time stamps.

    Anyway, if nanoseconds are added, one should think about good default formating. On second is 1.000.000.000 nanoseconds - and I guess nobody wants to spend time e.g. searching for minutes and seconds in long time stamps, in the output of borg list.

  5. mburghardt commented on Nov 2, 2026

    @mburghardt
    Author

    My personal use case is to compare the output of borg list--json... against a database that stores the file properties / checksums at the time of archive creation in order to ensure data integrity. As the originating filesystem provides nanosecond precision it seems only natural to me to use it, especially as Borg has the data internally.
    However, I agree with @PhrozenByte and @goebbe to differentiate between output like JSON or log files and text output that is intended to be read by humans.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions