diff options
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 |