Skip to content

Commit

Permalink
Add new placeholder keys
Browse files Browse the repository at this point in the history
  • Loading branch information
AdwaitSalankar committed Mar 5, 2024
1 parent b2cf5b1 commit 9f8b841
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/vorta/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os
import re
import socket
import subprocess
import sys
import unicodedata
from datetime import datetime as dt
Expand Down Expand Up @@ -416,14 +417,27 @@ def format_archive_name(profile, archive_name_tpl):
"""
hostname = socket.gethostname()
hostname = hostname.split(".")[0]
fqdn = _getfqdn(hostname)
borg_version = os.getenv("BORG_VERSION")
if not borg_version:
borg_version = subprocess.run(['borg', '--version'], stdout=subprocess.PIPE).stdout.decode('utf-8')
borg_version = borg_version.split(' ')[1]
borg_version_tuple = tuple(borg_version.split("."))
available_vars = {
'hostname': hostname,
'fqdn': _getfqdn(hostname),
'fqdn': fqdn,
'reverse-fqdn': ".".join(reversed(fqdn.split("."))),
'profile_id': profile.id,
'profile_slug': profile.slug(),
'now': dt.now(),
'utc_now': dt.utcnow(),
'utcnow': dt.utcnow(),
'user': getpass.getuser(),
'pid': os.getpid(),
'borgversion': borg_version,
'borgmajor': "%s" % borg_version_tuple[:1],
'borgminor': "%s.%s" % borg_version_tuple[:2],
'borgpatch': "%s.%s.%s" % borg_version_tuple[:3],
}
return archive_name_tpl.format(**available_vars)

Expand Down

0 comments on commit 9f8b841

Please sign in to comment.