Submit #3287
Updated by tuxillo over 3 years ago
Hi,
I'd like to propose a small modification to the way 220.snapshot-hammer2 handles scarce free space condition:
<pre>
<code class="diff">
diff --git a/etc/periodic/daily/220.snapshot-hammer2 b/etc/periodic/daily/220.snapshot-hammer2
index 09962dc3f3..36ea83ce8e 100644
--- a/etc/periodic/daily/220.snapshot-hammer2
+++ b/etc/periodic/daily/220.snapshot-hammer2
@@ -54,12 +54,12 @@ case "${snap_enable}" in
fi
_df=$(df ${dir} | grep -oE "[0-9]+%")
_pcnt=${_df%%%}
- if [ ${_pcnt} -gt ${snap_capacity} ]; then
- echo "omitted, not enough free space"
- continue
+ if [ ${_pcnt} -le ${snap_capacity} ]; then
+ hammer2 snapshot ${dir} ${dir}.${snap_tag}.$(date +%Y%m%d.%H:%M) \
+ || rc=1
+ else
+ echo "snapshot creation omitted, not enough free space"
fi
- hammer2 snapshot ${dir} ${dir}.${snap_tag}.$(date +%Y%m%d.%H:%M) \
- || rc=1
_keep=${snap_keep}
if [ "${_keep}" = "auto" ]; then
# adjust number of snapshots dynamically, according to free space
</code>
</pre>
The idea is that whenever the user falls into free space shortage situation, the "sliding window" of snapshots potentially continues rolling forward, instead of becoming stuck into the past.
BR,
--
Francis