diff options
author | George Hazan <ghazan@miranda.im> | 2020-06-14 13:55:06 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-06-14 13:55:06 +0300 |
commit | 52e4ddcd83b3b64bcf97fdfcfa1120c87b7b3eb4 (patch) | |
tree | 991ccd18cf211ae6e956d9d06002e351cd7a174d /libs/libmdbx/src/test/dump-load.sh | |
parent | 8862cf78b01bb4b9ae0da13b8e6acbf94f7c1cbe (diff) |
fixes #2450 (Update libmdbx to 0.8.1)
Diffstat (limited to 'libs/libmdbx/src/test/dump-load.sh')
-rw-r--r-- | libs/libmdbx/src/test/dump-load.sh | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/libs/libmdbx/src/test/dump-load.sh b/libs/libmdbx/src/test/dump-load.sh new file mode 100644 index 0000000000..55fa5c7f33 --- /dev/null +++ b/libs/libmdbx/src/test/dump-load.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +echo "------------------------------------------------------------------------------" + +if [ -z "$1" ]; then + echo "No mdbx-db pathname given"; + exit 2 +elif [ ! -e "$1" ]; then + echo "The mdbx-db '$1' don't exists"; + exit 2 +else + echo ">>>>>>>>>> $1" + RECO="$1.recovered" + rm -f dump1.txt dump2.txt "$RECO" + if ./mdbx_chk "$1"; then + echo ">>>>>>>>>> SOURCE VALID" + (./mdbx_dump -a "$1" > dump1.txt && \ + ./mdbx_load -nf dump1.txt "$RECO" && \ + ./mdbx_chk "$RECO" && \ + echo ">>>>>>>>>> DUMP/LOAD/CHK OK") || (echo ">>>>>>>>>> DUMP/LOAD/CHK FAILED"; exit 1) + REMOVE_RECO=1 + elif ./mdbx_chk -i "$1"; then + echo ">>>>>>>>>> SOURCE HAS WRONG-ORDER, TRY RECOVERY" + (./mdbx_dump -a "$1" > dump1.txt && \ + ./mdbx_load -anf dump1.txt "$RECO" && \ + ./mdbx_chk -i "$RECO" && \ + echo ">>>>>>>>>> DUMP/LOAD/CHK OK") || (echo ">>>>>>>>>> DUMP/LOAD/CHK FAILED"; exit 1) + REMOVE_RECO=0 + else + echo ">>>>>>>>>> SOURCE CORRUPTED, TRY RECOVERY" + (./mdbx_dump -ar "$1" > dump1.txt && \ + ./mdbx_load -ranf dump1.txt "$RECO" && \ + ./mdbx_chk -i "$RECO" && \ + echo ">>>>>>>>>> DUMP/LOAD/CHK OK") || (echo ">>>>>>>>>> DUMP/LOAD/CHK FAILED"; exit 1) + REMOVE_RECO=0 + fi + ./mdbx_dump -a "$RECO" > dump2.txt && diff -u dump1.txt dump2.txt && \ + rm -f dump1.txt dump2.txt && [ $REMOVE_RECO -ne 0 ] && rm -f "$RECO" + exit 0 +fi |