X-Git-Url: https://iankelling.org/git/?p=distro-setup;a=blobdiff_plain;f=check-subvol-stale;h=c585cea0169c2fb9bde14224380f252100f5067f;hp=bdb47492ef07b132914b21ec6773014675dca38f;hb=2d3ce30754a3f24d922635647bab4990b60f5c27;hpb=2cff2dd2b8040e6cbd721932ae09142881d7e0a6 diff --git a/check-subvol-stale b/check-subvol-stale index bdb4749..c585cea 100644 --- a/check-subvol-stale +++ b/check-subvol-stale @@ -13,16 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# usage: $0 SUBVOL_MOUNTPOINT... -# -# In git, this is not not executable because it's meant to be installed -# using ./install-my-scripts -# -# If latest subvols $@ are not mounted, exit 1, print message, and touch -# /nocow/btrfs-stale/$subvol -# -# Either SUBVOL_MOUNTPOINT is a snapshot of the latest, or -# the latest snapshot is snapshot of SUBVOL_MOUNTPOINT. [[ $EUID == 0 ]] || exec sudo -E "$BASH_SOURCE" "$@" @@ -31,6 +21,41 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR shopt -s nullglob +usage() { + cat </dev/null; then cgen=$(echo "$show" | sed -rn 's,^\s*Gen at creation:\s+([0-9]+).*,\1,p') - if [[ $cgen -gt $last_received_gen ]]; then + if [[ $cgen -gt $last_received_cgen ]]; then last_received_cgen=$cgen last_received=$f fi fi done + d last_received_cgen=$cgen + d last_received=$f # Get last_snap by date. # when a btrbk bugfix makes it into the distro, @@ -111,6 +146,7 @@ for d; do # 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') + d svp_cgen=$svp_cgen if [[ $svp_cgen -ge $last_received_cgen ]]; then stale=false else