Browse Source

Add placeholder for fqdn in reverse notation

(cherry picked from commit 85fb38e2f3d7c4df581f2aa58605a507003db492)
Gregor Kleen 7 years ago
parent
commit
dbf8d582f9
4 changed files with 10 additions and 0 deletions
  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.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.4/library/datetime.html#strftime-and-strptime-behavior>`_, e.g. {now:%Y-%m-%d_%H:%M:%S}

+ 3 - 0
src/borg/archiver.py

@@ -2093,6 +2093,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.4/library/datetime.html#strftime-and-strptime-behavior>`_, e.g. {now:%Y-%m-%d_%H:%M:%S}

+ 1 - 0
src/borg/helpers.py

@@ -664,6 +664,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()),