- # check if $d is a snapshot of any of the btrbk backups other than the latest
- if [[ ! $stale ]]; then
- for f in ${snaps[@]}; do
- if [[ $f == $last_snap ]]; then continue; fi
- uuid=$(btrfs sub show $f| awk '$1 == "UUID:" {print $2}')
- if btrfs sub show $d| grep "^\s*Parent UUID:\s*$uuid$" &>/dev/null; then
- stale=true
- echo "$d stale: it's a snapshot of $f"
- break
- fi
- done
- fi
- # check if $d generation is later than last_snap
- if [[ ! $stale ]]; then
- last_snap_gen=$(btrfs sub show $last_snap| awk '$1 == "Generation:" {print $2}')
- d_gen=$(btrfs sub show $d| awk '$1 == "Generation:" {print $2}')
- if (( d_gen < last_snap_gen )); then
+
+ # if there is a last_received, we can assume stale or fresh if we are newer/older
+ if [[ $last_received ]]; then
+ svp_cgen=$(btrfs sub show $svp | sed -rn 's,^\s*Gen at creation:\s+([0-9]+).*,\1,p')
+ if [[ $svp_cgen -ge $last_received_cgen ]]; then