before_everything / after_everything hook does not apply for "borgmatic info/list" #487

Closed
opened 2021-12-31 12:00:38 +00:00 by xLogiiCx · 2 comments

What I'm trying to do and why

Running a before/after-everything hook with borgmatic info / list.
By default my filesystem for Backups is mounted read-only.
When creating a Backup with borg i remount it read-write to create the Backup and then remount it back to read-only.
Works fine for borgmatic create but does not work at all when running info or list.

Steps to reproduce (if a bug)

Actual behavior (if a bug)

user@pc:~$ sudo borgmatic info --verbosity 2 
Ensuring legacy configuration is upgraded
/media/user/borgbackup/pc.borg: Displaying summary info for archives
borg info --debug --show-rc /media/user/borgbackup/pc.borg
using builtin fallback logging configuration
35 self tests completed in 0.05 seconds
Failed to create/acquire the lock /media/user/borgbackup/pc.borg/lock.exclusive ([Errno 30] Read-only file system: '/media/user/borgbackup/pc.borg/lock.exclusive').
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/borg/archiver.py", line 4703, in main
    exit_code = archiver.run(args)
  File "/usr/lib/python3/dist-packages/borg/archiver.py", line 4635, in run
    return set_ec(func(args))
  File "/usr/lib/python3/dist-packages/borg/archiver.py", line 162, in wrapper
    with repository:
  File "/usr/lib/python3/dist-packages/borg/repository.py", line 190, in __enter__
    self.open(self.path, bool(self.exclusive), lock_wait=self.lock_wait, lock=self.do_lock)
  File "/usr/lib/python3/dist-packages/borg/repository.py", line 421, in open
    self.lock = Lock(os.path.join(path, 'lock'), exclusive, timeout=lock_wait, kill_stale_locks=hostname_is_unique()).acquire()
  File "/usr/lib/python3/dist-packages/borg/locking.py", line 359, in acquire
    with self._lock:
  File "/usr/lib/python3/dist-packages/borg/locking.py", line 114, in __enter__
    return self.acquire()
  File "/usr/lib/python3/dist-packages/borg/locking.py", line 138, in acquire
    raise LockFailed(self.path, str(err)) from None
borg.locking.LockFailed: Failed to create/acquire the lock /media/user/borgbackup/pc.borg/lock.exclusive ([Errno 30] Read-only file system: '/media/user/borgbackup/pc.borg/lock.exclusive').
Platform: Linux pc 5.13.0-22-generic #22-Ubuntu SMP Fri Nov 5 13:21:36 UTC 2021 x86_64
Linux: Unknown Linux
Borg: 1.1.17  Python: CPython 3.9.7 msgpack: 0.5.6.+borg1
PID: 198601  CWD: /home/user
sys.argv: ['/usr/bin/borg', 'info', '--debug', '--show-rc', '/media/user/borgbackup/pc.borg']
SSH_ORIGINAL_COMMAND: None
terminating with error status, rc 2
/media/user/borgbackup/pc.borg: Error running actions for repository
Command 'borg info --debug --show-rc /media/user/borgbackup/pc.borg' returned non-zero exit status 2.
/etc/borgmatic/config.yaml: Error running configuration file

summary:
/etc/borgmatic/config.yaml: Error running configuration file
/media/user/borgbackup/pc.borg: Error running actions for repository
...
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/borg/archiver.py", line 4703, in main
    exit_code = archiver.run(args)
  File "/usr/lib/python3/dist-packages/borg/archiver.py", line 4635, in run
    return set_ec(func(args))
  File "/usr/lib/python3/dist-packages/borg/archiver.py", line 162, in wrapper
    with repository:
  File "/usr/lib/python3/dist-packages/borg/repository.py", line 190, in __enter__
    self.open(self.path, bool(self.exclusive), lock_wait=self.lock_wait, lock=self.do_lock)
  File "/usr/lib/python3/dist-packages/borg/repository.py", line 421, in open
    self.lock = Lock(os.path.join(path, 'lock'), exclusive, timeout=lock_wait, kill_stale_locks=hostname_is_unique()).acquire()
  File "/usr/lib/python3/dist-packages/borg/locking.py", line 359, in acquire
    with self._lock:
  File "/usr/lib/python3/dist-packages/borg/locking.py", line 114, in __enter__
    return self.acquire()
  File "/usr/lib/python3/dist-packages/borg/locking.py", line 138, in acquire
    raise LockFailed(self.path, str(err)) from None
borg.locking.LockFailed: Failed to create/acquire the lock /media/user/borgbackup/pc.borg/lock.exclusive ([Errno 30] Read-only file system: '/media/user/borgbackup/pc.borg/lock.exclusive').
Platform: Linux pc 5.13.0-22-generic #22-Ubuntu SMP Fri Nov 5 13:21:36 UTC 2021 x86_64
Linux: Unknown Linux
Borg: 1.1.17  Python: CPython 3.9.7 msgpack: 0.5.6.+borg1
PID: 198601  CWD: /home/user
sys.argv: ['/usr/bin/borg', 'info', '--debug', '--show-rc', '/media/user/borgbackup/pc.borg']
SSH_ORIGINAL_COMMAND: None
terminating with error status, rc 2
Command 'borg info --debug --show-rc /media/user/borgbackup/pc.borg' returned non-zero exit status 2.

Need some help? https://torsion.org/borgmatic/#issues

Expected behavior (if a bug)

Borgmatic should run the before_everything and the after_everything for all commands including "info" and "list".

Environment

borgmatic version: 1.5.13.dev0

borgmatic installation method: Ubuntu Package

Borg version: borg 1.1.17

Python version: Python 3.9.7

operating system and version: Ubuntu 21.10 x86_64

#### What I'm trying to do and why Running a before/after-everything hook with borgmatic info / list. By default my filesystem for Backups is mounted read-only. When creating a Backup with borg i remount it read-write to create the Backup and then remount it back to read-only. Works fine for borgmatic create but does not work at all when running info or list. #### Steps to reproduce (if a bug) #### Actual behavior (if a bug) ``` user@pc:~$ sudo borgmatic info --verbosity 2 Ensuring legacy configuration is upgraded /media/user/borgbackup/pc.borg: Displaying summary info for archives borg info --debug --show-rc /media/user/borgbackup/pc.borg using builtin fallback logging configuration 35 self tests completed in 0.05 seconds Failed to create/acquire the lock /media/user/borgbackup/pc.borg/lock.exclusive ([Errno 30] Read-only file system: '/media/user/borgbackup/pc.borg/lock.exclusive'). Traceback (most recent call last): File "/usr/lib/python3/dist-packages/borg/archiver.py", line 4703, in main exit_code = archiver.run(args) File "/usr/lib/python3/dist-packages/borg/archiver.py", line 4635, in run return set_ec(func(args)) File "/usr/lib/python3/dist-packages/borg/archiver.py", line 162, in wrapper with repository: File "/usr/lib/python3/dist-packages/borg/repository.py", line 190, in __enter__ self.open(self.path, bool(self.exclusive), lock_wait=self.lock_wait, lock=self.do_lock) File "/usr/lib/python3/dist-packages/borg/repository.py", line 421, in open self.lock = Lock(os.path.join(path, 'lock'), exclusive, timeout=lock_wait, kill_stale_locks=hostname_is_unique()).acquire() File "/usr/lib/python3/dist-packages/borg/locking.py", line 359, in acquire with self._lock: File "/usr/lib/python3/dist-packages/borg/locking.py", line 114, in __enter__ return self.acquire() File "/usr/lib/python3/dist-packages/borg/locking.py", line 138, in acquire raise LockFailed(self.path, str(err)) from None borg.locking.LockFailed: Failed to create/acquire the lock /media/user/borgbackup/pc.borg/lock.exclusive ([Errno 30] Read-only file system: '/media/user/borgbackup/pc.borg/lock.exclusive'). Platform: Linux pc 5.13.0-22-generic #22-Ubuntu SMP Fri Nov 5 13:21:36 UTC 2021 x86_64 Linux: Unknown Linux Borg: 1.1.17 Python: CPython 3.9.7 msgpack: 0.5.6.+borg1 PID: 198601 CWD: /home/user sys.argv: ['/usr/bin/borg', 'info', '--debug', '--show-rc', '/media/user/borgbackup/pc.borg'] SSH_ORIGINAL_COMMAND: None terminating with error status, rc 2 /media/user/borgbackup/pc.borg: Error running actions for repository Command 'borg info --debug --show-rc /media/user/borgbackup/pc.borg' returned non-zero exit status 2. /etc/borgmatic/config.yaml: Error running configuration file summary: /etc/borgmatic/config.yaml: Error running configuration file /media/user/borgbackup/pc.borg: Error running actions for repository ... Traceback (most recent call last): File "/usr/lib/python3/dist-packages/borg/archiver.py", line 4703, in main exit_code = archiver.run(args) File "/usr/lib/python3/dist-packages/borg/archiver.py", line 4635, in run return set_ec(func(args)) File "/usr/lib/python3/dist-packages/borg/archiver.py", line 162, in wrapper with repository: File "/usr/lib/python3/dist-packages/borg/repository.py", line 190, in __enter__ self.open(self.path, bool(self.exclusive), lock_wait=self.lock_wait, lock=self.do_lock) File "/usr/lib/python3/dist-packages/borg/repository.py", line 421, in open self.lock = Lock(os.path.join(path, 'lock'), exclusive, timeout=lock_wait, kill_stale_locks=hostname_is_unique()).acquire() File "/usr/lib/python3/dist-packages/borg/locking.py", line 359, in acquire with self._lock: File "/usr/lib/python3/dist-packages/borg/locking.py", line 114, in __enter__ return self.acquire() File "/usr/lib/python3/dist-packages/borg/locking.py", line 138, in acquire raise LockFailed(self.path, str(err)) from None borg.locking.LockFailed: Failed to create/acquire the lock /media/user/borgbackup/pc.borg/lock.exclusive ([Errno 30] Read-only file system: '/media/user/borgbackup/pc.borg/lock.exclusive'). Platform: Linux pc 5.13.0-22-generic #22-Ubuntu SMP Fri Nov 5 13:21:36 UTC 2021 x86_64 Linux: Unknown Linux Borg: 1.1.17 Python: CPython 3.9.7 msgpack: 0.5.6.+borg1 PID: 198601 CWD: /home/user sys.argv: ['/usr/bin/borg', 'info', '--debug', '--show-rc', '/media/user/borgbackup/pc.borg'] SSH_ORIGINAL_COMMAND: None terminating with error status, rc 2 Command 'borg info --debug --show-rc /media/user/borgbackup/pc.borg' returned non-zero exit status 2. Need some help? https://torsion.org/borgmatic/#issues ``` #### Expected behavior (if a bug) Borgmatic should run the before_everything and the after_everything for all commands including "info" and "list". #### Environment **borgmatic version:** 1.5.13.dev0 **borgmatic installation method:** Ubuntu Package **Borg version:** borg 1.1.17 **Python version:** Python 3.9.7 **operating system and version:** Ubuntu 21.10 x86_64

See #427 regarding --bypass-lock as another (perhaps better) way to solve this issue. In short, for such read-only operations you don't even need a lock.

See #427 regarding `--bypass-lock` as another (perhaps better) way to solve this issue. In short, for such read-only operations you don't even need a lock.
Owner

Thanks for filing this, but it looks like it's a duplicate of #463. I'll close this in favor of that ticket, but please feel free to follow along there.

Thanks for filing this, but it looks like it's a duplicate of #463. I'll close this in favor of that ticket, but please feel free to follow along there.
Sign in to join this conversation.
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#487
No description provided.