backup_root_path=$1 recovery_destination=$2 md5_zero="f1c9645dbc14efddc7d8a322685f26eb" # 10 MB zeros.. info_file=${backup_root_path}.md5CheckSums.info if [ ! -f $info_file ] then echo "no info file" echo $info_file exit 1 fi device_dir=$(grep checkDevicesDir0 $info_file |awk -F= '{print $2}') device=$(grep checkDevices0 $info_file |awk -F= '{print $2}' | awk -F/ '{print $2 "_" $3 "_" $4}' ) backup_path=$(echo ${backup_root_path}${device_dir}/${device}/) md5_file=$(echo ${backup_root_path}${device_dir}/${device}/.md5BlockCheckSums.bz2) bs=$(grep checkDevicesBS0 $info_file |awk -F= '{print $2}') count=$(bzcat ${md5_file} |wc -l) size=$(expr $bs \* $count) chunks=$(bzgrep -v $md5_zero $md5_file | awk '{print $3}' | xargs -n 1 basename | awk -F\. '{print $1}' ) if [ -a $recovery_destination ] then echo "destination exists" exit 1 fi dd if=/dev/zero bs=$bs count=0 seek=$count of=$recovery_destination &> /dev/null extract() { chunk=$1 bzcat ${backup_path}${chunk}.bz2 | dd of=$recovery_destination bs=$bs seek=$(expr $chunk - 1) conv=notrunc status=noxfer &> /dev/null } for chunk in $chunks do while [ `jobs | wc -l` -ge 8 ] do sleep 0.01 done extract $chunk & done