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.37k stars 29 forks source link

nilfs2 snapshots are not listed #134

Closed dmadisetti closed 1 month ago

dmadisetti commented 1 month ago

Is your feature request related to a problem? Please describe. I run ZFS, but I like my SD cards in NILFS2. I want to run httm on my flash cards, but it seems like it doesn't detect the snapshots

$> sudo /nix/store/4ja5k7wpj8p9izzwkcxsrcbslv5cjbdp-httm-0.42.3/bin/httm --debug thing

Config {
    paths: [
        PathData {
            path_buf: "/home/dylan/thing",
            metadata: Some(
                PathMetadata {
                    size: 20,
                    modify_time: SystemTime {
                        tv_sec: 1725461852,
                        tv_nsec: 82281830,
                    },
                },
            ),
        },
    ],
    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,
    dedup_by: Metadata,
    opt_bulk_exclusion: None,
    opt_last_snap: None,
    opt_preview: None,
    opt_deleted_mode: None,
    opt_requested_dir: None,
    requested_utc_offset: -04:00:00,
    exec_mode: BasicDisplay,
    print_mode: FormattedDefault,
    dataset_collection: FilesystemInfo {
        map_of_datasets: MapOfDatasets {
            inner: {
                "/home": DatasetMetadata {
                    source: "/dev/sdb1",
                    fs_type: Nilfs2,
                    link_type: Local,
                },
                "/nix": DatasetMetadata {
                    source: "xoot/nix",
                    fs_type: Zfs,
                    link_type: Local,
                },
                "/nix/store": DatasetMetadata {
                    source: "xoot/nix",
                    fs_type: Zfs,
                    link_type: Local,
                },
                "/xoot": DatasetMetadata {
                    source: "xoot",
                    fs_type: Zfs,
                    link_type: Local,
                },
            },
        },
        map_of_snaps: MapOfSnaps {
            inner: {
                "/home": [],
                "/nix": [],
                "/nix/store": [],
                "/xoot": [],
            },
        },
        filter_dirs: FilterDirs {
            inner: {
                "/",
                "/boot",
                "/dev",
                "/dev/hugepages",
                "/dev/mqueue",
                "/dev/pts",
                "/dev/shm",
                "/home/dylan/keybase",
                "/proc",
                "/run",
                "/run/credentials/getty@tty1.service",
                "/run/credentials/systemd-journald.service",
                "/run/credentials/systemd-sysctl.service",
                "/run/credentials/systemd-tmpfiles-resetup.service",
                "/run/credentials/systemd-tmpfiles-setup-dev-early.service",
                "/run/credentials/systemd-tmpfiles-setup-dev.service",
                "/run/credentials/systemd-tmpfiles-setup.service",
                "/run/credentials/systemd-vconsole-setup.service",
                "/run/keys",
                "/run/user/1337",
                "/run/wrappers",
                "/sys",
                "/sys/firmware/efi/efivars",
                "/sys/fs/bpf",
                "/sys/fs/cgroup",
                "/sys/fs/fuse/connections",
                "/sys/fs/pstore",
                "/sys/kernel/config",
                "/sys/kernel/debug",
                "/sys/kernel/security",
            },
        },
        opt_map_of_alts: None,
        opt_map_of_aliases: None,
        opt_common_snap_dir: None,
    },
    pwd: "/home/dylan",
}
────────────────────────────────────────────────────────
WARN: No snapshot version exists for the specified file.
────────────────────────────────────────────────────────
Wed Sep 04 10:57:32 2024  20 bytes  "/home/dylan/thing"
────────────────────────────────────────────────────────

Here's my /proc/mounts

devtmpfs /dev devtmpfs rw,nosuid,size=1628552k,nr_inodes=4067434,mode=755 0 0
devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=3,mode=620,ptmxmode=666 0 0
tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /run tmpfs rw,nosuid,nodev,size=8142748k,mode=755 0 0
ramfs /run/keys ramfs rw,nosuid,nodev,relatime,mode=750 0 0
sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
none / tmpfs rw,relatime 0 0
xoot/nix /nix zfs rw,relatime,xattr,noacl,casesensitive 0 0
xoot/nix /nix/store zfs ro,relatime,xattr,noacl,casesensitive 0 0
securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0
cgroup2 /sys/fs/cgroup cgroup2 rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot 0 0
pstore /sys/fs/pstore pstore rw,nosuid,nodev,noexec,relatime 0 0
efivarfs /sys/firmware/efi/efivars efivarfs rw,nosuid,nodev,noexec,relatime 0 0
bpf /sys/fs/bpf bpf rw,nosuid,nodev,noexec,relatime,mode=700 0 0
tmpfs /run/credentials/systemd-journald.service tmpfs ro,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mode=700,noswap 0 0
debugfs /sys/kernel/debug debugfs rw,nosuid,nodev,noexec,relatime 0 0
mqueue /dev/mqueue mqueue rw,nosuid,nodev,noexec,relatime 0 0
hugetlbfs /dev/hugepages hugetlbfs rw,nosuid,nodev,relatime,pagesize=2M 0 0
fusectl /sys/fs/fuse/connections fusectl rw,nosuid,nodev,noexec,relatime 0 0
configfs /sys/kernel/config configfs rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /run/credentials/systemd-tmpfiles-setup-dev-early.service tmpfs ro,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mode=700,noswap 0 0
tmpfs /run/credentials/systemd-sysctl.service tmpfs ro,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mode=700,noswap 0 0
tmpfs /run/credentials/systemd-tmpfiles-setup-dev.service tmpfs ro,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mode=700,noswap 0 0
xoot /xoot zfs rw,relatime,xattr,noacl,casesensitive 0 0
tmpfs /run/credentials/systemd-vconsole-setup.service tmpfs ro,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mode=700,noswap 0 0
tmpfs /run/wrappers tmpfs rw,nodev,relatime,mode=755 0 0
/dev/nvme0n1p1 /boot vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 0 0
/dev/sdb1 /home nilfs2 rw,relatime 0 0
tmpfs /run/credentials/systemd-tmpfiles-setup.service tmpfs ro,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mode=700,noswap 0 0
tmpfs /run/credentials/getty@tty1.service tmpfs ro,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mode=700,noswap 0 0
tmpfs /run/user/1337 tmpfs rw,nosuid,nodev,relatime,size=3257096k,nr_inodes=814274,mode=700,uid=1337,gid=100 0 0
/dev/fuse /home/dylan/keybase fuse rw,nosuid,nodev,relatime,user_id=1337,group_id=100 0 0
tmpfs /run/credentials/systemd-tmpfiles-resetup.service tmpfs ro,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mode=700,noswap 0 0

lscp shows me that snapshots are being taken, something is weird on the httm side.

Additional context Maybe due to proc_mounts churn? MapOfSnaps shouldn't be empty right

Cool project, obviously a lot of love put towards this, you should be proud

kimono-koans commented 1 month ago

MapOfSnaps shouldn't be empty right

Correct. No.

Re: nilfs2, you need to manually mount your snapshots. Actually you always need to mount your own snapshots, ZFS just has an auto-mounter and AFAIK nilfs2 doesn't.

lscp shows me that snapshots are being taken, something is weird on the httm side.

All the ZFS mount points should still contain ZFS snapshots, unless there are none? Are you taking ZFS snapshots?

On what I run, basically Ubuntu LTS, snapshots will be auto-mounted, even when the ZFS property snapdir is set to hidden. Try toggling that property to visible on a dataset on your system? This may also be some oddball nix thing where the snapshots are hidden to regular users? Maybe also try sudo? Check if you can see ZFS snapshots yourself via going to a ZFS base mount and running ls on the snapshot virtual directory: ls -alR /nix/.zfs/snapshot. Newer versions of samba over the network have required one to perform a readdir on the snapshot directory, in order for the snapshot auto-mount to kickstart, so I would check the output of mount after running ls -alR? Are the snapshots now auto-mounted after iterating over the snapshot directories?

In sum, my guess is it's some snapshot auto-mount issue, if it's not some privilege issue. I'd begin debugging by trying to make ZFS work correctly first. Feel free to check back in when you know more.

Cool project, obviously a lot of love put towards this, you should be proud

Thanks!

dmadisetti commented 1 month ago

Gottttt it. I didn't realize I had to explicitly mount the snapshots for nilfs2, I thought it might be auto-mounted too. I guess I could write a wrapper or fork to help me there.

Fresh install, zfs snapshots aren't set up yet- but thanks for checking

Thanks! Might be more of a documentation issue. I double checked and didn't see anything explicit. I just made the wrong assumption, and was confused

kimono-koans commented 1 month ago

I guess I could write a wrapper or fork to help me there.

If you figure out a clever way to auto-mount, or script mounting nilfs2 snapshots, I'd be pleased to add that script to the scripts folder. See: https://github.com/kimono-koans/httm/tree/master/scripts

The equine script is expressly for mounting Time Machine backups.

Thanks! Might be more of a documentation issue. I double checked and didn't see anything explicit. I just made the wrong assumption, and was confused

Also pleased to add some explanation to the README, or the --help. I'll think about where and what will be most helpful.

Perhaps there should just be warning when all MapOfSnaps values are empty? The issue here is that might not prevent your issue if you had had ZFS snapshots. Or perhap when all of a certain type contain no snapshots? I'm loath to make startup slower, but I'll try a few things.

kimono-koans commented 1 month ago

See re: additional debug info: https://github.com/kimono-koans/httm/commit/f2c8dbab762c7f19153174307f1db31914ba262e

dmadisetti commented 1 month ago

Perfect. I think this would have saved me 10 minutes