#!/usr/bin/env bash set -eux rm -rf save-dir-* rm -rf restore-dir-* rm -f to-be-saved/half-full if ! ln to-be-saved/half-empty to-be-saved/half-full > /dev/null 2>&1 then # EG, Haiku R1 alpha 3's BFS does not support hardlinks - in fact, BFS's on-disk # datastructures don't allow storing hardlinks, so adding them would be an # extension to the filesystem, on-disk. Frankly, I don't miss them; they're # too obscure. echo "$0: Your OS (filesystem) does not support hardlinks?" 1>&2 exit 0 fi hn=$(set -eu; hostname) (find ./to-be-saved -name .svn -prune -o -type f -print0 | xargs -0 md5sum -b | sort -k 2) > to-be-saved.md5sums for record in $(../../this-interpreter --variety all) do pyver=$(echo "$record" | awk -F'%' ' { print $1 }') interp=$(echo "$record" | awk -F'%' ' { print $2 }') mkdir -p save-dir-$pyver find to-be-saved -name .svn -prune -o -print0 | \ "$interp" ../../bin/backshift \ --save-directory save-dir-"$pyver" \ --backup \ --hostname "$hn" \ --subset test \ --init-savedir backup_id=$(set -eu; "$interp" ../../bin/backshift --save-directory save-dir-"$pyver" --list-backups | \ tail -1 | \ sed 's/ .*$//') rm -rf restore-dir-$"pyver" mkdir -p restore-dir-"$pyver" "$interp" ../../bin/backshift \ --save-directory save-dir-"$pyver" \ --produce-tar \ --backup-id "$backup_id" | \ (cd restore-dir-"$pyver" && tar xvf -) ( tbs=$(pwd) cd restore-dir-"$pyver" && \ mv ./"$tbs"/to-be-saved . ) (cd restore-dir-"$pyver" && find . -type f -print0 | xargs -0 md5sum -b | sort -k 2) > restore-dir-"$pyver".md5sums echo Diffing "$pyver" diff -C8 -b to-be-saved.md5sums restore-dir-"$pyver".md5sums pre_uniques=$(set -eu; find restore-dir-"$pyver"/to-be-saved -name .svn -prune -o -type f -print | ../equivs3d --skip-duplicates | sort) pre_duplicates=$(set -eu; find restore-dir-"$pyver"/to-be-saved -name .svn -prune -o -type f -print | ../equivs3d --skip-uniques | tr ' ' '\012' | sort) ( # We add a unique line to each line. In the the case of a 3-way hardlink, we add 3 lines. cd restore-dir-"$pyver"/to-be-saved for file in * do echo "$file" >> "$file" done ) # Now we make sure things are still the same post_uniques=$(set -eu; find restore-dir-"$pyver"/to-be-saved -name .svn -prune -o -type f -print | ../equivs3d --skip-duplicates | sort) post_duplicates=$(set -eu; find restore-dir-"$pyver"/to-be-saved -name .svn -prune -o -type f -print | ../equivs3d --skip-uniques | tr ' ' '\012' | sort) if [ "$pre_uniques" != "$post_uniques" ] then ( echo "$0: Unique files changed:" echo "$pre_uniques" echo echo "$post_uniques" ) exit 1 fi if [ "$pre_duplicates" != "$post_duplicates" ] then ( echo "$0: Unique files changed:" echo "$pre_duplicates" echo echo "$post_duplicates" ) exit 1 fi if [ $(echo "$post_uniques" | wc -l) != 3 ] then echo "$0: Bad number of uniques" 1>&2 exit 1 fi if [ $(echo "$post_duplicates" | wc -l) != 2 ] then echo "$0: Bad number of duplicates" 1>&2 exit 1 fi done