Przeglądaj źródła

Merge pull request #1423 from leo-b/1.0-maint-version_placeholder

borgversion placeholder 1.0-maint
TW 8 lat temu
rodzic
commit
3456bb08a5
3 zmienionych plików z 13 dodań i 4 usunięć
  1. 8 3
      borg/archiver.py
  2. 2 1
      borg/helpers.py
  3. 3 0
      borg/remote.py

+ 8 - 3
borg/archiver.py

@@ -829,7 +829,8 @@ class Archiver:
             EOF
             $ borg create --exclude-from exclude.txt backup /\n\n''')
     helptext['placeholders'] = textwrap.dedent('''
-        Repository (or Archive) URLs and --prefix values support these placeholders:
+        Repository (or Archive) URLs, --prefix and --remote-path values support these
+        placeholders:
 
         {hostname}
 
@@ -855,7 +856,11 @@ class Archiver:
 
             The current process ID.
 
-        Examples::
+        {borgversion}
+
+            The version of borg.
+
+       Examples::
 
             borg create /path/to/repo::{hostname}-{user}-{utcnow} ...
             borg create /path/to/repo::{hostname}-{now:%Y-%m-%d_%H:%M:%S} ...
@@ -1069,7 +1074,7 @@ class Archiver:
         checkpoints and treated in special ways.
 
         In the archive name, you may use the following format tags:
-        {now}, {utcnow}, {fqdn}, {hostname}, {user}, {pid}
+        {now}, {utcnow}, {fqdn}, {hostname}, {user}, {pid}, {borgversion}
 
         To speed up pulling backups over sshfs and similar network file systems which do
         not provide correct inode information the --ignore-inode flag can be used. This

+ 2 - 1
borg/helpers.py

@@ -577,7 +577,8 @@ def replace_placeholders(text):
         'hostname': socket.gethostname(),
         'now': current_time.now(),
         'utcnow': current_time.utcnow(),
-        'user': uid2user(os.getuid(), os.getuid())
+        'user': uid2user(os.getuid(), os.getuid()),
+        'borgversion': borg_version,
     }
     return format_line(text, data)
 

+ 3 - 0
borg/remote.py

@@ -11,6 +11,7 @@ import tempfile
 from . import __version__
 
 from .helpers import Error, IntegrityError, sysinfo
+from .helpers import replace_placeholders
 from .repository import Repository
 
 import msgpack
@@ -159,6 +160,7 @@ class RemoteRepository:
             # that the system's ssh binary picks up (non-matching) libraries from there
             env.pop('LD_LIBRARY_PATH', None)
         env.pop('BORG_PASSPHRASE', None)  # security: do not give secrets to subprocess
+        env['BORG_VERSION'] = __version__
         self.p = Popen(borg_cmd, bufsize=0, stdin=PIPE, stdout=PIPE, stderr=PIPE, env=env)
         self.stdin_fd = self.p.stdin.fileno()
         self.stdout_fd = self.p.stdout.fileno()
@@ -235,6 +237,7 @@ class RemoteRepository:
             return [sys.executable, '-m', 'borg.archiver', 'serve'] + opts + self.extra_test_args
         else:  # pragma: no cover
             remote_path = args.remote_path or os.environ.get('BORG_REMOTE_PATH', 'borg')
+            remote_path = replace_placeholders(remote_path)
             return [remote_path, 'serve'] + opts
 
     def ssh_cmd(self, location):