1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-26 09:47:58 +00:00

add new placeholder {borgversion}

substitute placeholders in --remote-path
add BORG_VERSION environment variable before executing ssh command
This commit is contained in:
Alexander 'Leo' Bergolth 2016-07-28 09:30:46 +02:00
parent e32dcc4c8a
commit 54048a339c
3 changed files with 13 additions and 4 deletions

View file

@ -826,7 +826,8 @@ def do_break_lock(self, args, repository):
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}
@ -852,7 +853,11 @@ def do_break_lock(self, args, repository):
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} ...
@ -1064,7 +1069,7 @@ def build_parser(self, args=None, prog=None):
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

View file

@ -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)

View file

@ -11,6 +11,7 @@
from . import __version__
from .helpers import Error, IntegrityError, sysinfo
from .helpers import replace_placeholders
from .repository import Repository
import msgpack
@ -155,6 +156,7 @@ def __init__(self, location, create=False, lock_wait=None, lock=True, args=None)
# 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()
@ -221,6 +223,7 @@ def borg_cmd(self, args, testing):
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):