1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-29 11:16:43 +00:00

add BORG_HOST_ID, fixes #3985

(cherry picked from commit 90348c1de9)
This commit is contained in:
Thomas Waldmann 2018-08-04 15:01:48 +02:00
parent 64f2fc0a65
commit 901e3a7888
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

@ -210,7 +210,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():