aboutsummaryrefslogtreecommitdiff
path: root/exp/exp.sh
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2021-10-04 20:37:50 +0200
committern-peugnet <n.peugnet@free.fr>2021-10-04 20:37:50 +0200
commit6897c0ae70892e40fd7603e4d00662038c01a82d (patch)
treec116766c1eb4ccd0187a56860100752c63295d9e /exp/exp.sh
parentb5842cb956aeac90bdf26a5ad26c86c594fe30ee (diff)
downloaddna-backup-6897c0ae70892e40fd7603e4d00662038c01a82d.tar.gz
dna-backup-6897c0ae70892e40fd7603e4d00662038c01a82d.zip
add checks for consistency
It works ok, but man, git is good
Diffstat (limited to 'exp/exp.sh')
-rwxr-xr-xexp/exp.sh30
1 files changed, 28 insertions, 2 deletions
diff --git a/exp/exp.sh b/exp/exp.sh
index 9edf367..59a5ef1 100755
--- a/exp/exp.sh
+++ b/exp/exp.sh
@@ -1,6 +1,7 @@
#!/bin/bash
# This script expects the following variables to be exported:
+# - DNA_BACKUP: the path to dna-backup binary
# - REPO_PATH: the path of the repo the experiment is based on
# - MAX_VERSION: the max number for versions for the experiment
# - COMMITS: the name of the file that contains the lists of versions
@@ -20,10 +21,35 @@ do
$GITC checkout $hash
# create diff for this version
- $GITC diff --minimal --binary --unified=0 $prev | gzip > $DIFFS/$i.diff.gz
+ $GITC diff --minimal --binary --unified=0 $prev \
+ | gzip \
+ > "$DIFFS/$i.diff.gz"
# create backup for this version
- ../dna-backup commit -v 2 $REPO_PATH $BACKUP
+ $DNA_BACKUP commit -v 2 $REPO_PATH $BACKUP
+
+ if [[ $(( $i % 4 )) == 0 ]]
+ then
+ # check diff correctness
+ TEMP=$(mktemp -d)
+ for n in $(seq 0 $i)
+ do
+ cat "$DIFFS/$n.diff.gz" \
+ | gzip --decompress \
+ | git -C $TEMP apply --binary --unidiff-zero --whitespace=nowarn - \
+ || echo "Git patchs do not match source"
+ done
+ cp $REPO_PATH/.git $TEMP/
+ diff --brief --recursive $REPO_PATH $TEMP \
+ || echo "dna-backup restore do not match source"
+ rm -rf $TEMP
+
+ # check backup correctness
+ TEMP=$(mktemp -d)
+ $DNA_BACKUP restore -v 2 $BACKUP $TEMP
+ diff --brief --recursive $REPO_PATH $TEMP
+ rm -rf $TEMP
+ fi
prev=$hash
let i++