mirror of
https://github.com/borgbackup/borg.git
synced 2025-03-03 18:27:01 +00:00
BORG_HOSTNAME_IS_UNIQUE=yes by default.
This commit is contained in:
parent
d79da81d22
commit
bb6b4fde93
6 changed files with 22 additions and 17 deletions
|
@ -128,6 +128,13 @@ The best check that everything is ok is to run a dry-run extraction::
|
|||
Changelog
|
||||
=========
|
||||
|
||||
Version 1.1.0b5 (not released)
|
||||
------------------------------
|
||||
|
||||
Compatibility notes:
|
||||
|
||||
- BORG_HOSTNAME_IS_UNIQUE is now on by default.
|
||||
|
||||
Version 1.1.0b4 (2017-03-27)
|
||||
----------------------------
|
||||
|
||||
|
|
|
@ -140,9 +140,10 @@ General:
|
|||
Main usecase for this is to fully automate ``borg change-passphrase``.
|
||||
BORG_DISPLAY_PASSPHRASE
|
||||
When set, use the value to answer the "display the passphrase for verification" question when defining a new passphrase for encrypted repositories.
|
||||
BORG_HOSTNAME_IS_UNIQUE=yes
|
||||
Use this to assert that your hostname is unique.
|
||||
Borg will then automatically remove locks that it could determine to be stale.
|
||||
BORG_HOSTNAME_IS_UNIQUE=no
|
||||
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_LOGGING_CONF
|
||||
When set, use the given filename as INI_-style logging configuration.
|
||||
BORG_RSH
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
from .helpers import int_to_bigint, bigint_to_int, bin_to_hex
|
||||
from .helpers import format_file_size
|
||||
from .helpers import safe_ns
|
||||
from .helpers import yes
|
||||
from .helpers import yes, hostname_is_unique
|
||||
from .helpers import remove_surrogates
|
||||
from .helpers import ProgressIndicatorPercent, ProgressIndicatorMessage
|
||||
from .item import Item, ArchiveItem, ChunkListEntry
|
||||
|
@ -187,9 +187,6 @@ def __init__(self, repository, key, manifest, path=None, sync=True, do_files=Fal
|
|||
self.progress = progress
|
||||
self.path = path or os.path.join(get_cache_dir(), repository.id_str)
|
||||
self.security_manager = SecurityManager(repository)
|
||||
self.hostname_is_unique = yes(env_var_override='BORG_HOSTNAME_IS_UNIQUE', prompt=False, env_msg=None)
|
||||
if self.hostname_is_unique:
|
||||
logger.info('Enabled removal of stale cache locks')
|
||||
self.do_files = do_files
|
||||
# Warn user before sending data to a never seen before unencrypted repository
|
||||
if not os.path.exists(self.path):
|
||||
|
@ -295,7 +292,7 @@ def _do_open(self):
|
|||
def open(self, lock_wait=None):
|
||||
if not os.path.isdir(self.path):
|
||||
raise Exception('%s Does not look like a Borg cache' % self.path)
|
||||
self.lock = Lock(os.path.join(self.path, 'lock'), exclusive=True, timeout=lock_wait, kill_stale_locks=self.hostname_is_unique).acquire()
|
||||
self.lock = Lock(os.path.join(self.path, 'lock'), exclusive=True, timeout=lock_wait, kill_stale_locks=hostname_is_unique()).acquire()
|
||||
self.rollback()
|
||||
|
||||
def close(self):
|
||||
|
|
|
@ -1478,6 +1478,10 @@ def output(msg, msg_type, is_prompt=False, **kwargs):
|
|||
env_var_override = None
|
||||
|
||||
|
||||
def hostname_is_unique():
|
||||
return yes(env_var_override='BORG_HOSTNAME_IS_UNIQUE', prompt=False, env_msg=None, default=True)
|
||||
|
||||
|
||||
def ellipsis_truncate(msg, space):
|
||||
"""
|
||||
shorten a long string by adding ellipsis between it and return it, example:
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
import shlex
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
import traceback
|
||||
import textwrap
|
||||
import time
|
||||
|
@ -22,7 +21,7 @@
|
|||
from .helpers import sysinfo
|
||||
from .helpers import bin_to_hex
|
||||
from .helpers import replace_placeholders
|
||||
from .helpers import yes
|
||||
from .helpers import hostname_is_unique
|
||||
from .repository import Repository, MAX_OBJECT_SIZE, LIST_SCAN_LIMIT
|
||||
from .version import parse_version, format_version
|
||||
from .logger import create_logger
|
||||
|
@ -646,8 +645,8 @@ def borg_cmd(self, args, testing):
|
|||
except AttributeError:
|
||||
pass
|
||||
env_vars = []
|
||||
if yes(env_var_override='BORG_HOSTNAME_IS_UNIQUE', env_msg=None, prompt=False):
|
||||
env_vars.append('BORG_HOSTNAME_IS_UNIQUE=yes')
|
||||
if not hostname_is_unique():
|
||||
env_vars.append('BORG_HOSTNAME_IS_UNIQUE=no')
|
||||
if testing:
|
||||
return env_vars + [sys.executable, '-m', 'borg.archiver', 'serve'] + opts + self.extra_test_args
|
||||
else: # pragma: no cover
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
from .helpers import Location
|
||||
from .helpers import ProgressIndicatorPercent
|
||||
from .helpers import bin_to_hex
|
||||
from .helpers import yes
|
||||
from .helpers import hostname_is_unique
|
||||
from .helpers import secure_erase
|
||||
from .locking import Lock, LockError, LockErrorT
|
||||
from .logger import create_logger
|
||||
|
@ -124,9 +124,6 @@ def __init__(self, path, create=False, exclusive=False, lock_wait=None, lock=Tru
|
|||
self.created = False
|
||||
self.exclusive = exclusive
|
||||
self.append_only = append_only
|
||||
self.hostname_is_unique = yes(env_var_override='BORG_HOSTNAME_IS_UNIQUE', env_msg=None, prompt=False)
|
||||
if self.hostname_is_unique:
|
||||
logger.info('Enabled removal of stale repository locks')
|
||||
|
||||
def __del__(self):
|
||||
if self.lock:
|
||||
|
@ -279,7 +276,7 @@ def open(self, path, exclusive, lock_wait=None, lock=True):
|
|||
if not os.path.isdir(path):
|
||||
raise self.DoesNotExist(path)
|
||||
if lock:
|
||||
self.lock = Lock(os.path.join(path, 'lock'), exclusive, timeout=lock_wait, kill_stale_locks=self.hostname_is_unique).acquire()
|
||||
self.lock = Lock(os.path.join(path, 'lock'), exclusive, timeout=lock_wait, kill_stale_locks=hostname_is_unique()).acquire()
|
||||
else:
|
||||
self.lock = None
|
||||
self.config = ConfigParser(interpolation=None)
|
||||
|
|
Loading…
Reference in a new issue