[Errno 17] File exists while running borgmatic check #711

Closed
opened 2023-06-11 17:05:19 +00:00 by flyinggreenfrog · 13 comments

What I'm trying to do and why

After upgrading from borgmatic 1.7.10 to 1.7.13 borgmatic check fails with following error:

ssh://XXXX@XXXX/./YYYY: Error running actions for repository
[Errno 17] File exists: '/root/.borgmatic/checks/971dd166ae0ba8f621740de76f43e0984a0ee1cdbf378f7776adec3c7d41d132/data'

Steps to reproduce (if a bug)

Having run borgmatic check in version 1.7.10 for repository created the file /root/.borgmatic/checks/.../data.

With newer version 1.7.13 borgmatic check wants to create a file /root/.borgmatic/checks/.../data/all instead, but can't handle the situation, when data as file already exists, but needs to be now a directory.

Actual behavior (if a bug)

borgmatic check fails with

ssh://XXXX@XXXX/./YYYY: Error running actions for repository
[Errno 17] File exists: '/root/.borgmatic/checks/971dd166ae0ba8f621740de76f43e0984a0ee1cdbf378f7776adec3c7d41d132/data'

Expected behavior (if a bug)

borgmatic check should run successfully

Other notes / implementation ideas

Workaround/Solution: after upgrading to borgmatic 1.7.13 manually delete the /root/.borgmatic/checks/.../data file, and a new run will create subdirectory data with now used file data/all.

Alternatively create empty file data/all before a new run.

Environment

borgmatic version: 1.7.13

borgmatic installation method: openSUSE package

Borg version: borg 1.2.4

Python version: 3.10.11

Database version (if applicable): -

operating system and version: openSUSE Tumbleweed

#### What I'm trying to do and why After upgrading from borgmatic 1.7.10 to 1.7.13 `borgmatic check` fails with following error: ``` ssh://XXXX@XXXX/./YYYY: Error running actions for repository [Errno 17] File exists: '/root/.borgmatic/checks/971dd166ae0ba8f621740de76f43e0984a0ee1cdbf378f7776adec3c7d41d132/data' ``` #### Steps to reproduce (if a bug) Having run `borgmatic check` in version 1.7.10 for repository created the file `/root/.borgmatic/checks/.../data`. With newer version 1.7.13 `borgmatic check` wants to create a file `/root/.borgmatic/checks/.../data/all` instead, but can't handle the situation, when `data` as file already exists, but needs to be now a directory. #### Actual behavior (if a bug) `borgmatic check` fails with ``` ssh://XXXX@XXXX/./YYYY: Error running actions for repository [Errno 17] File exists: '/root/.borgmatic/checks/971dd166ae0ba8f621740de76f43e0984a0ee1cdbf378f7776adec3c7d41d132/data' ``` #### Expected behavior (if a bug) `borgmatic check` should run successfully #### Other notes / implementation ideas **Workaround/Solution:** after upgrading to borgmatic 1.7.13 manually delete the `/root/.borgmatic/checks/.../data` file, and a new run will create subdirectory `data` with now used file `data/all`. Alternatively create empty file `data/all` before a new run. #### Environment **borgmatic version:** 1.7.13 **borgmatic installation method:** openSUSE package **Borg version:** borg 1.2.4 **Python version:** 3.10.11 **Database version (if applicable):** - **operating system and version:** openSUSE Tumbleweed
Owner

Ugh, thanks for filing this. The new check code is supposed to gracefully upgrade the old check file layout in place, but it sounds like that's not working in your case. I'll see if I can repro this locally.

Ugh, thanks for filing this. The new check code is supposed to gracefully upgrade the old check file layout in place, but it sounds like that's not working in your case. I'll see if I can repro this locally.
witten added the
bug
label 2023-06-11 17:10:57 +00:00
Owner

Can I get a look at your borgmatic --verbosity 2 logs when this error occurs? In particular, I'm looking for a log like:

Upgrading archives check time from /root/.borgmatic/checks/971dd166ae0ba8f621740de76f43e0984a0ee1cdbf378f7776adec3c7d41d132/data to /root/.borgmatic/checks/971dd166ae0ba8f621740de76f43e0984a0ee1cdbf378f7776adec3c7d41d132/data/all

Thanks!

(FWIW, I've not been able to reproduce the error locally.)

Can I get a look at your `borgmatic --verbosity 2` logs when this error occurs? In particular, I'm looking for a log like: ``` Upgrading archives check time from /root/.borgmatic/checks/971dd166ae0ba8f621740de76f43e0984a0ee1cdbf378f7776adec3c7d41d132/data to /root/.borgmatic/checks/971dd166ae0ba8f621740de76f43e0984a0ee1cdbf378f7776adec3c7d41d132/data/all ``` Thanks! (FWIW, I've not been able to reproduce the error locally.)

Thanks for your reply.

I will try to provide logs, but in the error logs (borgmatic check -v 2) from my attempts earlier no such line Upgrading archives check time ... appeared.

At the moment it works again for me, as I was manually deleting that data file.

Hopefully on next weekend I would try to reproduce it again with old version, before upgrading again.

Thanks for your reply. I will try to provide logs, but in the error logs (`borgmatic check -v 2`) from my attempts earlier no such line `Upgrading archives check time ...` appeared. At the moment it works again for me, as I was manually deleting that `data` file. Hopefully on next weekend I would try to reproduce it again with old version, before upgrading again.
Owner

Okay. If it comes to it, I can give you a modified source file instrumented with even more debug logging to determine what might be going on with these check upgrades on your system. Keep me updated!

Okay. If it comes to it, I can give you a modified source file instrumented with even _more_ debug logging to determine what might be going on with these check upgrades on your system. Keep me updated!
witten added the
waiting for response
label 2023-06-11 23:24:06 +00:00
Owner

Possibly related: #713.

Possibly related: #713.

@witten I am getting something similar in my borg extract tests from rsync.net:

...
archives
root/.borgmatic/checks/45c964b6df60b853411b175cff99e289f90957e1486142ca4e3f62678bbf1de8/archives: open: [Errno 21] Is a directory: '/alloc/data/archives'
repository
archives
root/.borgmatic/checks/5104269ce93ba0783c8b115fd072b71f947e1e6b9970d650b1a375eb3d018cee/archives: open: [Errno 21] Is a directory: '/alloc/data/archives'
repository
archives
root/.borgmatic/checks/f2e38ccc990b318897dc030d786be9b4e97818f87ba2abcece7ea4a3178bd4fd/archives: open: [Errno 21] Is a directory: '/alloc/data/archives'
repository
archives
root/.borgmatic/checks/404985c24bc47e7856b17ea72cf6a9f9aa85dc9e96c3a02f14d95d153d5ff9c3/archives: open: [Errno 21] Is a directory: '/alloc/data/archives'
archives
archives/all
repository
archives
archives/all
repository
RemoteRepository: 149.98 kB bytes sent, 2.74 GB bytes received, 2837 messages sent 

I am running something like this on in a Docker container on Nomad (Hashicorp):

cd $NOMAD_ALLOC_DIR/data && borg --bypass-lock list --last 1 --short $BORG_REPO_TARGET | head -n1 | xargs -n1 -I% borg --bypass-lock extract --strip-components 4 $BORG_REPO_TARGET::%

This was working fine until I moved from borgmatic 1.7.12 to 1.7.14.

@witten I am getting something similar in my borg extract tests from rsync.net: ``` ... archives root/.borgmatic/checks/45c964b6df60b853411b175cff99e289f90957e1486142ca4e3f62678bbf1de8/archives: open: [Errno 21] Is a directory: '/alloc/data/archives' repository archives root/.borgmatic/checks/5104269ce93ba0783c8b115fd072b71f947e1e6b9970d650b1a375eb3d018cee/archives: open: [Errno 21] Is a directory: '/alloc/data/archives' repository archives root/.borgmatic/checks/f2e38ccc990b318897dc030d786be9b4e97818f87ba2abcece7ea4a3178bd4fd/archives: open: [Errno 21] Is a directory: '/alloc/data/archives' repository archives root/.borgmatic/checks/404985c24bc47e7856b17ea72cf6a9f9aa85dc9e96c3a02f14d95d153d5ff9c3/archives: open: [Errno 21] Is a directory: '/alloc/data/archives' archives archives/all repository archives archives/all repository RemoteRepository: 149.98 kB bytes sent, 2.74 GB bytes received, 2837 messages sent ``` I am running something like this on in a Docker container on Nomad (Hashicorp): ``` cd $NOMAD_ALLOC_DIR/data && borg --bypass-lock list --last 1 --short $BORG_REPO_TARGET | head -n1 | xargs -n1 -I% borg --bypass-lock extract --strip-components 4 $BORG_REPO_TARGET::% ``` This was working fine until I moved from borgmatic 1.7.12 to 1.7.14.
Owner

Thanks for chiming in! If you have the ability to install a development version of borgmatic, I have a potential fix you can try. You would upgrade borgmatic with the version in that branch. Or, if it's easier, I can give you a single file to override one of your local borgmatic source files with.

But if you're not comfortable with that for whatever reason, you can just wait for the next release and this should hopefully be fixed.

Thanks for chiming in! If you have the ability to install a development version of borgmatic, I have [a potential fix you can try](https://projects.torsion.org/borgmatic-collective/borgmatic/src/branch/713-check-time-upgrade-debugging). You would upgrade borgmatic with the version in that branch. Or, if it's easier, I can give you a single file to override one of your local borgmatic source files with. But if you're not comfortable with that for whatever reason, you can just wait for the next release and this should hopefully be fixed.

@witten I figured out why root/.borgmatic/checks/404985c24bc47e7856b17ea72cf6a9f9aa85dc9e96c3a02f14d95d153d5ff9c3/archives: open: [Errno 21] Is a directory: '/alloc/data/archives' happened.

I take borg backups of zfs snapshots that are mounted to something like /mnt/borg/r02/data/

Then the database folder is inside that.

However, when stripping 4 components root/.borgmatic/checks/404985c24bc47e7856b17ea72cf6a9f9aa85dc9e96c3a02f14d95d153d5ff9c3/archives

ended up in same place as borg's archives folder.

@witten I figured out why `root/.borgmatic/checks/404985c24bc47e7856b17ea72cf6a9f9aa85dc9e96c3a02f14d95d153d5ff9c3/archives: open: [Errno 21] Is a directory: '/alloc/data/archives'` happened. I take borg backups of zfs snapshots that are mounted to something like `/mnt/borg/r02/data/` Then the database folder is inside that. However, when stripping 4 components `root/.borgmatic/checks/404985c24bc47e7856b17ea72cf6a9f9aa85dc9e96c3a02f14d95d153d5ff9c3/archives` ended up in same place as borg's archives folder.
Owner

Interesting. I assume those ZFS snapshots read-only? That might explain why borgmatic couldn't upgrade their file layout (which changed from 1.7.12. to 1.7.14). The ~/.borgmatic/checks/ directory needs to be read-write.

Interesting. I assume those ZFS snapshots read-only? That might explain why borgmatic couldn't upgrade their file layout (which changed from 1.7.12. to 1.7.14). The `~/.borgmatic/checks/` directory needs to be read-write.

@witten Yep, snapshots mounted as read-only locally, then shipped to rsync.net with borgmatic.
Verification is done in a docker/nomad combo using borgmatic docker container. I got it running again without that error after removal of --strip-components

@witten Yep, snapshots mounted as read-only locally, then shipped to rsync.net with borgmatic. Verification is done in a docker/nomad combo using borgmatic docker container. I got it running again without that error after removal of --strip-components
Owner

Got it, thanks.

Got it, thanks.
witten removed the
waiting for response
label 2023-06-23 17:35:42 +00:00
Owner

I believe this ticket to be fixed now as part of the work on #713. The fix should be part of the next release.

I believe this ticket to be fixed now as part of the work on #713. The fix should be part of the next release.
Owner

Just released in borgmatic 1.7.15.

Just released in borgmatic 1.7.15.
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#711
No description provided.