Bläddra i källkod

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

borgversion placeholder 1.0-maint
TW 8 år sedan
förälder
incheckning
3456bb08a5
3 ändrade filer med 13 tillägg och 4 borttagningar
  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
             EOF
             $ borg create --exclude-from exclude.txt backup /\n\n''')
             $ borg create --exclude-from exclude.txt backup /\n\n''')
     helptext['placeholders'] = textwrap.dedent('''
     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}
         {hostname}
 
 
@@ -855,7 +856,11 @@ class Archiver:
 
 
             The current process ID.
             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}-{user}-{utcnow} ...
             borg create /path/to/repo::{hostname}-{now:%Y-%m-%d_%H:%M:%S} ...
             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.
         checkpoints and treated in special ways.
 
 
         In the archive name, you may use the following format tags:
         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
         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
         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(),
         'hostname': socket.gethostname(),
         'now': current_time.now(),
         'now': current_time.now(),
         'utcnow': current_time.utcnow(),
         'utcnow': current_time.utcnow(),
-        'user': uid2user(os.getuid(), os.getuid())
+        'user': uid2user(os.getuid(), os.getuid()),
+        'borgversion': borg_version,
     }
     }
     return format_line(text, data)
     return format_line(text, data)
 
 

+ 3 - 0
borg/remote.py

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