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

restic mount on macOS #128

Closed uwe-schwarz closed 4 months ago

uwe-schwarz commented 4 months ago

Before you begin Before you begin:

  1. Have you tried with the latest version of httm? yes, 0.40.3 via brew

  2. Have you read the README and/or the help (httm -h or man httm)? yes

    A bug report which requests a fix for an issue which is already described within the README is a request for technical support, not a bug report, and will be treated as low priority and may be summarily closed ("Answer is contained within the README."). One example I've seen:

    Bug Report: "httm doesn't appear to work with my btrfs layout..."

    Answer contained within the README: "btrfs, by default, creates snapshots as the privileged user. That may mean you will need to invoke httm with sudo or its equivalent. httm will not fail if it does not have privileges to any particular snapshot directory."

  3. Is this actually a bug report?

    A bug report which demonstrates that a package is not installable via an unsupported method is probably a feature request, not a bug report, and may also be summarily closed ("This is a feature request not a bug report. Please submit via the feature request form.").

    The supported install methods are only those contained within the README. Note, rpm is one install method described in the README, but rpm is not yum or dnf. If you can't install via dnf or yum (you may be able to?), and you'd like to, that would be a feature request. If your distribution/operating system uses an old or incompatible version of rustc or cargo or libc, and httm will not, for some reason, install, that is also probably a feature request.

Describe the bug

restic v0.17 (https://github.com/restic/restic/blob/master/CHANGELOG.md#changelog-for-restic-0170-2024-07-26) supports restic mount on macOS. httm reports:

Error: No supported Restic datasets were found on the system.

I didn't find any documentation about telling httm where the mount point is.

To Reproduce Steps to reproduce the behavior:

  1. restic mount … /tmp/r
  2. httm --alt-store=restic

Expected behavior

httm should either find the restic mount point or let me specify it.

Additional context Add any other context about the problem here. Perhaps you should include system details like:

uwe-schwarz commented 4 months ago

Forgot the mount point restic uses:

fuse-t:/restic on /private/tmp/r (nfs, nodev, nosuid, read-only, mounted by user)
kimono-koans commented 4 months ago

This branch should fix your bug: https://github.com/kimono-koans/httm/tree/fix-restic-fuse-mount-name-macos.

Please confirm by installing from source using cargo: cargo install --git https://github.com/kimono-koans/httm.git --branch "fix-restic-fuse-mount-name-macos"

kimono-koans commented 4 months ago

Merged here: https://github.com/kimono-koans/httm/commit/50f4568ad7b37d0abf6197e49cb4ec2857afaef2

uwe-schwarz commented 4 months ago

Thanks for responding and fixing so quickly. It looks like it's finding the repository now, but I get this:

WARN: No snapshot version exists for the specified file.

When I'm using httm --alt-store=timemachine it finds snapshots.

I'm just using the example from the readme: httm --alt-store=restic -R -s --preview . (the directory is present in the restic snapshot, I double checked).

kimono-koans commented 4 months ago

Thanks for responding and fixing so quickly. It looks like it's finding the repository now, but I get this:

See the README:

Note: Users may need to use sudo (or equivalent) to view versions on BTRFS or NILFS2 datasets, or Restic repositories, as BTRFS or NILFS2 snapshots or Restic repositories may require root permissions in order to be visible. Restic and Time Machine backups also require an additional flag, see further discussion of Restic --alt-store in the below.

How is your restic repo mounted? Is it mounted at a mountpoint only root can read, like so:

restic on /mnt type fuse (ro,nosuid,nodev,relatime,user_id=0,group_id=0)

If so, use sudo. If not, I'll need to see your output including the debug flag: httm --debug --alt-store=restic ~/.zshrc

uwe-schwarz commented 4 months ago

It's mounted on /tmp/r (or /private/tmp/r) as my user. I can access all the files in the repo, including the snapshots.

The snapshot path gets correctly recognized:

❯ httm --debug --alt-store=restic ~/.zprofile
Config {
    paths: [
        PathData {
            path_buf: "/Users/uwe/.zprofile",
            metadata: Some(
                PathMetadata {
                    size: 43,
                    modify_time: SystemTime {
                        tv_sec: 1710519407,
                        tv_nsec: 787876169,
                    },
                },
            ),
        },
    ],
    opt_recursive: false,
    opt_exact: false,
    opt_no_filter: false,
    opt_debug: true,
    opt_no_traverse: false,
    opt_omit_ditto: false,
    opt_no_hidden: false,
    opt_json: false,
    opt_one_filesystem: false,
    opt_no_clones: false,
    uniqueness: UniqueMetadata,
    opt_bulk_exclusion: None,
    opt_last_snap: None,
    opt_preview: None,
    opt_deleted_mode: None,
    opt_requested_dir: None,
    requested_utc_offset: +02:00:00,
    exec_mode: BasicDisplay,
    print_mode: FormattedDefault,
    dataset_collection: FilesystemInfo {
        map_of_datasets: MapOfDatasets {
            inner: {
                "/": DatasetMetadata {
                    source: "restic",
                    fs_type: Restic(
                        Some(
                            [
                                "/private/tmp/r/snapshots/2024-07-27T22:30:05+02:00",
                            ],
                        ),
                    ),
                },
            },
        },
        map_of_snaps: MapOfSnaps {
            inner: {
                "/": [],
            },
        },
        filter_dirs: FilterDirs {
            inner: {
                "/System/Volumes/Hardware",
                "/System/Volumes/Data/home",
                "/System/Volumes/Update",
                "/",
                "/dev",
                "/System/Volumes/Preboot",
                "/Library/Developer/CoreSimulator/Volumes/iOS_21F79",
                "/System/Volumes/xarts",
                "/Volumes/backup",
                "/System/Volumes/iSCPreboot",
                "/Volumes/restic",
                "/Users/uwe/OrbStack",
                "/System/Volumes/Data",
                "/System/Volumes/VM",
            },
        },
        opt_map_of_alts: None,
        opt_map_of_aliases: None,
        opt_common_snap_dir: None,
    },
    pwd: "/Users/uwe",
}
──────────────────────────────────────────────────────────
WARN: No snapshot version exists for the specified file.
──────────────────────────────────────────────────────────
Fri Mar 15 18:16:47 2024  43 bytes  "/Users/uwe/.zprofile"
──────────────────────────────────────────────────────────

I also tried with sudo, just to be sure, but it gets the same result.

The file is present in a bunch of snapshots:

❯ ls -l /tmp/r/snapshots/*/Users/uwe/.zprofile | wc -l
      56

And just to be extra sure I created a snapshot with a different version of the file:

…
.rw-r--r-- 43 uwe 2024-03-15 18:16 /tmp/r/snapshots/2024-07-27T20:31:38+02:00/Users/uwe/.zprofile
.rw-r--r-- 43 uwe 2024-03-15 18:16 /tmp/r/snapshots/2024-07-27T22:30:05+02:00/Users/uwe/.zprofile
.rw-r--r-- 42 uwe 2024-07-27 23:12 /tmp/r/snapshots/2024-07-27T23:12:45+02:00/Users/uwe/.zprofile
.rw-r--r-- 42 uwe 2024-07-27 23:12 /tmp/r/snapshots/latest/Users/uwe/.zprofile

Still the same result with httm as above.

kimono-koans commented 4 months ago

This is unusual:

map_of_datasets: MapOfDatasets {
            inner: {
                "/": DatasetMetadata {
                    source: "restic",
                    fs_type: Restic(
                        Some(
                            [
                                "/private/tmp/r/snapshots/2024-07-27T22:30:05+02:00",
                            ],
                        ),
                    ),
                },
            },
        },

What is your mount output?

Your dataset should be at the base of the repo, or /private/tmp/r like you indicated earlier, not an individual snapshot:

fuse-t:/restic on /private/tmp/r (nfs, nodev, nosuid, read-only, mounted by user)

Oops. This may be my mistake as I have worked in support for browsing from the restic latest directory. I'm sorry if it has broken this. Ugh. This is why you shouldn't do development after a few beers on the couch.

kimono-koans commented 4 months ago

This should fix: https://github.com/kimono-koans/httm/tree/fix-restic-root-discovery

You can install via: cargo install --git https://github.com/kimono-koans/httm.git --branch "fix-restic-root-discovery"

uwe-schwarz commented 4 months ago

Yes, thanks again. It's working with that branch.