add BORG_HOST_ID, fixes #3985

This commit is contained in:
Thomas Waldmann 2018-08-04 15:01:48 +02:00
parent f7069f6c3b
commit 90348c1de9
2 changed files with 14 additions and 1 deletions

View File

@ -185,6 +185,13 @@ General:
Borg assumes that it can derive a unique hostname / identity (see ``borg debug info``).
If this is not the case or you do not want Borg to automatically remove stale locks,
set this to *no*.
BORG_HOST_ID
Borg usually computes a host id from the FQDN plus the results of ``uuid.getnode()`` (which usually returns
a unique id based on the MAC address of the network interface. Except if that MAC happens to be all-zero - in
that case it returns a random value, which is not what we want (because it kills automatic stale lock removal).
So, if you have a all-zero MAC address or other reasons to better externally control the host id, just set this
environment variable to a unique value. If all your FQDNs are unique, you can just use the FQDN. If not,
use fqdn@uniqueid.
BORG_LOGGING_CONF
When set, use the given filename as INI_-style logging configuration.
BORG_RSH

View File

@ -249,7 +249,13 @@ def getfqdn(name=''):
# XXX this sometimes requires live internet access for issuing a DNS query in the background.
hostname = socket.gethostname()
fqdn = getfqdn(hostname)
hostid = '%s@%s' % (fqdn, uuid.getnode())
# uuid.getnode() is problematic in some environments (e.g. OpenVZ, see #3968) where the virtual MAC address
# is all-zero. uuid.getnode falls back to returning a random value in that case, which is not what we want.
# thus, we offer BORG_HOST_ID where a user can set an own, unique id for each of his hosts.
hostid = os.environ.get('BORG_HOST_ID')
if not hostid:
hostid = '%s@%s' % (fqdn, uuid.getnode())
def get_process_id():