automorphism88 / snapraid-btrfs

Script for using snapraid with btrfs snapshots
GNU General Public License v3.0
134 stars 15 forks source link

[suggestion] replace snapper with btrbk #17

Open zilexa opened 3 years ago

zilexa commented 3 years ago

A few reasons for this:

Also, I often experience non-documented or poorly documented issues with snapper:

And also, the single most important reason:

btrbk seems so much more straightforward (and catches errors).

I am trying to start fresh (new parity disk, deleted all content files). I created new config files via snapper CLI, snapper works. snapraid-btrfs still doesn't find any configs:

$ snapraid-btrfs ls --verbose
Snapper configs found:

snapraid-btrfs: No snapper configs found for any data drives in /etc/snapraid.conf 

Even though snapraid.conf:

data d1 /mnt/disks/cache/data
data d2 /mnt/disks/data1/data
data d3 /mnt/disks/data2/data

/etc/snapper/configs has files cache, data, data2 each containing the exact path that d1, d2, d3 have in the snapraid.conf.

aprayoga commented 3 years ago

hi @zilexa , I recently got similar issue as yours. snapraid-btrfs could not find config even though it is listed on snapper and snapraid.conf. After some time debugging, I found out for some reason the subvolume mount point got extra trailing space. My solution is to insert following line into line 688 to strip the trailing space subvol="${subvol%"${subvol##*[![:space:]]}"}"

the full code for your reference

find_configs_try() {
    local config field1 field2 field3 found subvol
    config="$1"
    found=
    if subvol="$("$my_snapper" -c "$config" get-config 2>/dev/null |
        sed -e '/^SUBVOLUME /!d' -e 's/^SUBVOLUME[ ]*| //')"
    then
        subvol="${subvol%"${subvol##*[![:space:]]}"}"
        while IFS=$' \t' read -r field1 field2 field3 ; do
            if [[ "$field1" =~ ^(data|disk)$ ]] &&
                   [[ "$field3" -ef "$subvol" ]]
            then
                found=1
                snapper_configs+=( "$config" )
                snapper_subvols[$config]="$subvol"
                snapraid_names[$config]="$field2"
            fi
        done < "$config_file"
        if [[ "$found" ]] ; then
            verbose \
                "Found $subvol in $config_file - using snapper config $config"
            return 0
        else
            return 1
        fi
    else
        return 2
    fi
}
dim-geo commented 2 years ago

And also, the single most important reason:

storing snapshots within the snapped subvolume makes absolutely no sense. I you delete the subvolume or it becomes >inaccessible, so does the snapshot folder within. Snapshots belong next to the snapped subvolume, not within. btrbk does this >neatly.

This can be addressed by an alternative snapshot layout of snapper