diff --git a/docs/usage/general/environment.rst.inc b/docs/usage/general/environment.rst.inc index b4a0a8280..b896586af 100644 --- a/docs/usage/general/environment.rst.inc +++ b/docs/usage/general/environment.rst.inc @@ -99,6 +99,11 @@ General: Using this does not affect data safety, but might result in a more bursty write to disk behaviour (not continuously streaming to disk). + retry_erofs + Retry opening a file without O_NOATIME if opening a file with O_NOATIME + caused EROFS. You will need this to make archives from volume shadow copies + in WSL1 (Windows Subsystem for Linux 1). + Some automatic "answerers" (if set, they automatically answer confirmation questions): BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=no (or =yes) For "Warning: Attempting to access a previously unknown unencrypted repository" diff --git a/src/borg/helpers/fs.py b/src/borg/helpers/fs.py index d52ce5f12..8e99c7bd4 100644 --- a/src/borg/helpers/fs.py +++ b/src/borg/helpers/fs.py @@ -286,6 +286,13 @@ def os_open(*, flags, path=None, parent_fd=None, name=None, noatime=False): raise # Was this EPERM due to the O_NOATIME flag? Try again without it: fd = os.open(fname, _flags_normal, dir_fd=parent_fd) + except OSError as exc: + # O_NOATIME causes EROFS when accessing a volume shadow copy in WSL1 + from . import workarounds + if 'retry_erofs' in workarounds and exc.errno == errno.EROFS and _flags_noatime != _flags_normal: + fd = os.open(fname, _flags_normal, dir_fd=parent_fd) + else: + raise else: fd = os.open(fname, _flags_normal, dir_fd=parent_fd) return fd