kimono-koans / httm

Interactive, file-level Time Machine-like tool for ZFS/btrfs/nilfs2 (and even Time Machine and Restic backups!)
https://crates.io/crates/httm
Mozilla Public License 2.0
1.38k stars 29 forks source link

Error mounting local snapshots under MacOS - is this error related to "not for use with ... direct attached storage"? #126

Closed e12e closed 4 months ago

e12e commented 4 months ago

Before you begin

  1. Have you tried with the latest version of httm? Via "brew", yes. See below.
  2. Have you read the README and/or the help (httm -h or man httm)? Yes.
  3. Is this actually a bug report? I belive so.

This might be the a case of unclear error message and wrong use (TimeMachine and DAS).

Describe the bug Running sudo equine --mount-localresults in "Operation not permitted" error:

sudo equine --mount-local
Discovering backup locations (this can take a few seconds)...
Mounting snapshots...
mkdir: /Volumes/com.apple.TimeMachine.localsnapshots/Backups.backupdb/emily.local: Operation not permitted

To Reproduce Steps to reproduce the behavior:

  1. sudo equine --mount-local
  2. See error

Possibly related - opening the native macOS TimeMachine UI to verify that TimeMachine is working (maybe it sets up some protected mounts that conflict with httm?).

Expected behavior Either TimeMachine snapshots should be mounted, or if it is possible to check if the use-case is unsupported, an error/hint to that effect should be output ("Unable to create folder for mount points - this could be due to trying to use httm with direct attached storage").

Additional context I'm trying to run this on an m2 MacBook Air, with TimeMachine on an external usb3 ssd drive. I am a little uncertain if this is what is reffered to as unsupported use-case (direct attached storage, DAS). Technically it certainly is a DAS, on the other hand I would expect httm to either fail gracefully/earlier, fail at something other than permission for creating folder for mount-points, or simiply fail quietly and horribly when/if the DAS is removed :-) ).

The error is certainly consistent with the errors I can provoke manually - so I'm wondering if there's some other edge case here with MacOS version?

IE:

# I have snapshots:
tmutil listlocalsnapshots /System/Volumes/Data | head -3
Snapshots for disk /System/Volumes/Data:
com.apple.TimeMachine.2024-07-22-202810.local
com.apple.TimeMachine.2024-07-22-212819.local

# There's something odd with access rights to the TimeMachine volume path:
sudo stat /Volumes/com.apple.TimeMachine.localsnapshots/
16777239 72984296 drwxr-xr-x 3 root wheel 0 96 "Jul 23 19:36:06 2024" "Jul 23 19:36:06 2024" "Jul 23 19:36:06 2024" "Jul 23 19:36:06 2024" 4096 0 0 /Volumes/com.apple.TimeMachine.localsnapshots/

sudo ls /Volumes/com.apple.TimeMachine.localsnapshots/
ls: /Volumes/com.apple.TimeMachine.localsnapshots/: Operation not permitted

sudo mkdir -p /Volumes/com.apple.TimeMachine.localsnapshots/Backups.backupdb/emily.local
mkdir: /Volumes/com.apple.TimeMachine.localsnapshots/Backups.backupdb/emily.local: Operation not permitted

# I have mounts of snapshots:
mount |grep -E '2024-07-22-(202810|212819)/(ventura|Data)'
com.apple.TimeMachine.2024-07-22-212819.local@/dev/disk4s1 on /Volumes/com.apple.TimeMachine.localsnapshots/Backups.backupdb/emily/2024-07-22-212819/ventura - Data (apfs, local, read-only, journaled, nobrowse, protect)
com.apple.TimeMachine.2024-07-22-202810.local@/dev/disk4s1 on /Volumes/com.apple.TimeMachine.localsnapshots/Backups.backupdb/emily/2024-07-22-202810/ventura - Data (apfs, local, read-only, journaled, nobrowse, protect)
com.apple.TimeMachine.2024-07-22-212819.local@/dev/disk4s5 on /Volumes/com.apple.TimeMachine.localsnapshots/Backups.backupdb/emily/2024-07-22-212819/Data (apfs, local, read-only, journaled, nobrowse, protect)
com.apple.TimeMachine.2024-07-22-202810.local@/dev/disk4s5 on /Volumes/com.apple.TimeMachine.localsnapshots/Backups.backupdb/emily/2024-07-22-202810/Data (apfs, local, read-only, journaled, nobrowse, protect)

(Note that httm wants to make a mountpoint "emily.local" while these are "emily" (just hostname).

system_profiler SPSoftwareDataType -detailLevel mini
Software:

    System Software Overview:

      System Version: macOS 14.5 (23F79)
      Kernel Version: Darwin 23.5.0
      Time since boot: 7 days, 7 hours, 8 minutes

uname -av
Darwin emily.local 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:19:05 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8112 arm64
kimono-koans commented 4 months ago

Thanks for filing a bug report. I'm sorry httm isn't working as expected for you.

sudo ls /Volumes/com.apple.TimeMachine.localsnapshots/
ls: /Volumes/com.apple.TimeMachine.localsnapshots/: Operation not permitted

I don't have the same permissions issue on my Macbook. I am also running 14.5 with SIP fully enabled.

You need to root cause your permissions issue before I can help. You may need to use chflags clear the user immutable flag (see nouchg). You may need to disable SIP and dtruss the execution of mkdir -p to actually know what's going on.

Possibly related - opening the native macOS TimeMachine UI to verify that TimeMachine is working (maybe it sets up some protected mounts that conflict with httm?).

Probably not, but you should investigate and report back.

Expected behavior Either TimeMachine snapshots should be mounted, or if it is possible to check if the use-case is unsupported, an error/hint to that effect should be output ("Unable to create folder for mount points - this could be due to trying to use httm with direct attached storage").

I don't think we know enough to print an error like that yet. It could just be permissions on your machine. I mean -- equine --mount-local snapshots shouldn't implicate any DAS specific issues. But I would also remove the DAS drive and simply test local TM snapshots again to make sure.

I'm trying to run this on an m2 MacBook Air, with TimeMachine on an external usb3 ssd drive. I am a little uncertain if this is what is reffered to as unsupported use-case (direct attached storage, DAS). Technically it certainly is a DAS, on the other hand I would expect httm to either fail gracefully/earlier, fail at something other than permission for creating folder for mount-points, or simiply fail quietly and horribly when/if the DAS is removed :-) ).

Note also that equine does not support DAS. See equine -h:

equine is a script to connect to the Time Machine network volume (NAS), mount
the image file, and finally, mount all APFS snapshots necessary to use with httm.
This script is not for use with Time Machines which utilize direct attached
storage (DAS).
...

I'm still interested in assisting you, if making local snapshots work created for use with a DAS is something easy. Just note that because I don't have a DAS, etc., I may summarily close as unsupported.

e12e commented 4 months ago

Looks like having DAS attached was the core issue - see end of message.

I don't have the same permissions issue on my Macbook. I am also running 14.5 with SIP fully enabled.

Ok. Odd.

equine --mount-local snapshots shouldn't implicate any DAS specific issues.

Right, that was my thought as well.

It's defintly TimeMachine that controls /Volumes/com.apple.TimeMachine.localsnapshots - while looking at it now it dissappeared from under /Volumes as the current backup completed. Then when opening the TimeMachine UI it reappeared again.

I struggle to make my machine reveal any hidden flags etc - it appears to be entirely normal:

ls -lO@d /Volumes/com.apple.TimeMachine.localsnapshots
drwxr-xr-x  3 root  wheel  - 96 Jul 26 17:05 /Volumes/com.apple.TimeMachine.localsnapshots

However anything under localsnapshots is mounted nobrowse, protect - but I can't find out how the parent folder itself is locked, eg:

ount |grep Backups.backupdb|head -1
com.apple.TimeMachine.2024-07-26-155229.local@/dev/disk4s1 on /Volumes/com.apple.TimeMachine.localsnapshots/Backups.backupdb/emily/2024-07-26-155229/ventura - Data (apfs, local, read-only, journaled, nobrowse, protect)

I can (as root) create folders under /Volumes as expected.

After disconnecting my backup drive, I can run equine --mount-local without error - but that is probably just because it can't find any snapshots, and so doesn't try to create any folders/mounts....?

Although, there should be some:

tmutil listlocalsnapshots /System/Volumes/Data 
Snapshots for disk /System/Volumes/Data:
com.apple.TimeMachine.2024-07-25-174739.local
com.apple.TimeMachine.2024-07-25-184741.local
com.apple.TimeMachine.2024-07-25-194812.local
#(... snip ...)
com.apple.TimeMachine.2024-07-26-155229.local
com.apple.TimeMachine.2024-07-26-165245.local

I guess this can be closed as trying to use httm with DAS for TimeMachine - which isn't supported.