summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-06-21 11:01:27 +0200
committerErich Eckner <git@eckner.net>2019-06-21 11:01:27 +0200
commit8383a03f122bc866f8b77e4b312778c97cd77622 (patch)
treec8d37ebec13b2ad0024ac814fcd5204b7c6e632b
parentd857a6b30949599b0fccd79840859c2c82ba47b8 (diff)
downloadbuilder-8383a03f122bc866f8b77e4b312778c97cd77622.tar.xz
bin/bisect-database-dumps new to bisect through the database dumps
-rwxr-xr-xbin/bisect-database-dumps60
1 files changed, 60 insertions, 0 deletions
diff --git a/bin/bisect-database-dumps b/bin/bisect-database-dumps
new file mode 100755
index 0000000..c943107
--- /dev/null
+++ b/bin/bisect-database-dumps
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+dumps=$(
+ find '/data/backup' -mindepth 1 -maxdepth 1 -name 'database-*.xz' -exec ls -tr {} +
+)
+
+has=$(
+ printf '%s\n' "$dumps" | \
+ tail -n1
+)
+
+if ! xzgrep -q "$@" "${has}"; then
+ >&2 printf 'cannot find "%s" in the latest dump\n' "$*"
+fi
+
+has_not=$(
+ printf '%s\n' "$dumps" | \
+ head -n1
+)
+
+if xzgrep -q "$@" "${has_not}"; then
+ >&2 printf 'first dump does also have "%s"\n' "$*"
+fi
+
+count=$(
+ printf '%s\n' "${dumps}" | \
+ wc -l
+)
+
+>&2 printf '%s dumps to check\n' "${count}"
+
+while [ "${count}" -gt 2 ]; do
+ pivot=$(
+ printf '%s\n' "${dumps}" | \
+ sed -n '
+ \@^'"${has_not}"'$@,\@^'"${has}"'$@p
+ ' | \
+ sed -n '
+ '"$((count/2+1))"' p
+ '
+ )
+ >&2 printf 'looking into "%s" ... ' "${pivot}"
+ if xzgrep -q "$@" "${pivot}"; then
+ >&2 printf 'has'
+ has="${pivot}"
+ else
+ >&2 printf 'has not'
+ has_not="${pivot}"
+ fi
+ count=$(
+ printf '%s\n' "${dumps}" | \
+ sed -n '
+ \@^'"${has_not}"'$@,\@^'"${has}"'$@p
+ ' | \
+ wc -l
+ )
+ >&2 printf ' (%s dumps remaining)\n' "${count}"
+done
+
+printf '%s has not\n%s has\n' "${has_not}" "${has}"