mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-22 22:22:27 +00:00
new BORG_WORKAROUNDS mechanism, basesyncfile, fixes #4710
remove WSL autodetection. if WSL still has this problem, you need to
set BORG_WORKAROUNDS=basesyncfile in the borg process environment to
work around it.
(cherry picked from commit beb948fc71
)
This commit is contained in:
parent
373bd8abd3
commit
b43d3bb7fa
3 changed files with 22 additions and 16 deletions
|
@ -218,6 +218,18 @@ General:
|
||||||
When set to no (default: yes), system information (like OS, Python version, ...) in
|
When set to no (default: yes), system information (like OS, Python version, ...) in
|
||||||
exceptions is not shown.
|
exceptions is not shown.
|
||||||
Please only use for good reasons as it makes issues harder to analyze.
|
Please only use for good reasons as it makes issues harder to analyze.
|
||||||
|
BORG_WORKAROUNDS
|
||||||
|
A list of comma separated strings that trigger workarounds in borg,
|
||||||
|
e.g. to work around bugs in other software.
|
||||||
|
|
||||||
|
Currently known strings are:
|
||||||
|
|
||||||
|
basesyncfile
|
||||||
|
Use the more simple BaseSyncFile code to avoid issues with sync_file_range.
|
||||||
|
You might need this to run borg on WSL (Windows Subsystem for Linux) or
|
||||||
|
in systemd.nspawn containers on some architectures (e.g. ARM).
|
||||||
|
Using this does not affect data safety, but might result in a more bursty
|
||||||
|
write to disk behaviour (not continuously streaming to disk).
|
||||||
TMPDIR
|
TMPDIR
|
||||||
where temporary files are stored (might need a lot of temporary space for some operations), see tempfile_ for details
|
where temporary files are stored (might need a lot of temporary space for some operations), see tempfile_ for details
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,11 @@
|
||||||
from .msgpack import is_slow_msgpack, is_supported_msgpack, int_to_bigint, bigint_to_int, get_limited_unpacker
|
from .msgpack import is_slow_msgpack, is_supported_msgpack, int_to_bigint, bigint_to_int, get_limited_unpacker
|
||||||
from . import msgpack
|
from . import msgpack
|
||||||
|
|
||||||
|
# generic mechanism to enable users to invoke workarounds by setting the
|
||||||
|
# BORG_WORKAROUNDS environment variable to a list of comma-separated strings.
|
||||||
|
# see the docs for a list of known workaround strings.
|
||||||
|
workarounds = tuple(os.environ.get('BORG_WORKAROUNDS', '').split(','))
|
||||||
|
|
||||||
"""
|
"""
|
||||||
The global exit_code variable is used so that modules other than archiver can increase the program exit code if a
|
The global exit_code variable is used so that modules other than archiver can increase the program exit code if a
|
||||||
warning or error occurred during their operation. This is different from archiver.exit_code, which is only accessible
|
warning or error occurred during their operation. This is different from archiver.exit_code, which is only accessible
|
||||||
|
|
|
@ -5,6 +5,7 @@ import subprocess
|
||||||
|
|
||||||
from .posix import posix_acl_use_stored_uid_gid
|
from .posix import posix_acl_use_stored_uid_gid
|
||||||
from .posix import user2uid, group2gid
|
from .posix import user2uid, group2gid
|
||||||
|
from ..helpers import workarounds
|
||||||
from ..helpers import safe_decode, safe_encode
|
from ..helpers import safe_decode, safe_encode
|
||||||
from .base import SyncFile as BaseSyncFile
|
from .base import SyncFile as BaseSyncFile
|
||||||
from .base import safe_fadvise
|
from .base import safe_fadvise
|
||||||
|
@ -316,23 +317,11 @@ cdef _sync_file_range(fd, offset, length, flags):
|
||||||
cdef unsigned PAGE_MASK = sysconf(_SC_PAGESIZE) - 1
|
cdef unsigned PAGE_MASK = sysconf(_SC_PAGESIZE) - 1
|
||||||
|
|
||||||
|
|
||||||
def _is_WSL():
|
if 'basesyncfile' in workarounds:
|
||||||
"""detect Windows Subsystem for Linux"""
|
|
||||||
try:
|
|
||||||
with open('/proc/version') as fd:
|
|
||||||
linux_version = fd.read()
|
|
||||||
# hopefully no non-WSL Linux will ever mention 'Microsoft' in the kernel version:
|
|
||||||
return 'Microsoft' in linux_version
|
|
||||||
except: # noqa
|
|
||||||
# make sure to never ever crash due to this check.
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
if _is_WSL():
|
|
||||||
class SyncFile(BaseSyncFile):
|
class SyncFile(BaseSyncFile):
|
||||||
# if we are on Microsoft's "Windows Subsytem for Linux", use the
|
# if we are on platforms with a broken or not implemented sync_file_range,
|
||||||
# more generic BaseSyncFile to avoid issues like seen there:
|
# use the more generic BaseSyncFile to avoid issues.
|
||||||
# https://github.com/borgbackup/borg/issues/1961
|
# see basesyncfile description in our docs for details.
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
# a real Linux, so we can do better. :)
|
# a real Linux, so we can do better. :)
|
||||||
|
|
Loading…
Reference in a new issue