소스 검색

Add placeholder for fqdn in reverse notation

Gregor Kleen 7 년 전
부모
커밋
85fb38e2f3
4개의 변경된 파일10개의 추가작업 그리고 0개의 파일을 삭제
  1. 3 0
      docs/man/borg-placeholders.1
  2. 3 0
      docs/usage/help.rst.inc
  3. 3 0
      src/borg/archiver.py
  4. 1 0
      src/borg/helpers/parseformat.py

+ 3 - 0
docs/man/borg-placeholders.1

@@ -42,6 +42,9 @@ The (short) hostname of the machine.
 .B {fqdn}
 The full name of the machine.
 .TP
+.B {reverse-fqdn}
+The full name of the machine in reverse domain name notation.
+.TP
 .B {now}
 The current local date and time, by default in ISO\-8601 format.
 You can also supply your own \fI\%format string\fP, e.g. {now:%Y\-%m\-%d_%H:%M:%S}

+ 3 - 0
docs/usage/help.rst.inc

@@ -169,6 +169,9 @@ placeholders:
 {fqdn}
     The full name of the machine.
 
+{reverse-fqdn}
+    The full name of the machine in reverse domain name notation.
+
 {now}
     The current local date and time, by default in ISO-8601 format.
     You can also supply your own `format string <https://docs.python.org/3.5/library/datetime.html#strftime-and-strptime-behavior>`_, e.g. {now:%Y-%m-%d_%H:%M:%S}

+ 3 - 0
src/borg/archiver.py

@@ -1901,6 +1901,9 @@ class Archiver:
         {fqdn}
             The full name of the machine.
 
+        {reverse-fqdn}
+            The full name of the machine in reverse domain name notation.
+
         {now}
             The current local date and time, by default in ISO-8601 format.
             You can also supply your own `format string <https://docs.python.org/3.5/library/datetime.html#strftime-and-strptime-behavior>`_, e.g. {now:%Y-%m-%d_%H:%M:%S}

+ 1 - 0
src/borg/helpers/parseformat.py

@@ -183,6 +183,7 @@ def replace_placeholders(text):
     data = {
         'pid': os.getpid(),
         'fqdn': socket.getfqdn(),
+        'reverse-fqdn': '.'.join(reversed(socket.getfqdn().split('.'))),
         'hostname': socket.gethostname(),
         'now': DatetimeWrapper(current_time.now()),
         'utcnow': DatetimeWrapper(current_time.utcnow()),