Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # NB: Must run with -1 for until full first pass is complete
- firstrun=
- sleep=$(( 60 * 60 * 6 )) # 6h
- #?sleep=300 # 5m
- while getopts 1hs: flag; do
- case "$flag" in
- 1) firstrun=1 ;;
- s) sleep="$OPTARG" ;;
- *) echo "$0 [-1h] [from [to [log]]]" >&2
- exit 1
- esac
- done
- shift $(( $OPTIND - 1 ))
- : "${from:=${1:-/dev/ada1}}"
- : "${to:=${2:-/dev/ada2}}"
- : "${log:=${3:-Recovery.log}}"
- n=0
- set -e
- while :; do
- set -- -f -v -v -n -r1
- n=$(( $n + 1 ))
- if [ "$firstrun" ]; then
- set -- "$@" -a 1048576
- elif [ $(( $n % 2 )) -eq 0 ]; then
- set -- "$@" -M -R -C
- #? set -- "$@" -R -C
- else
- set -- "$@" -M -C
- #? set -- "$@" -C
- fi
- set -- ddrescue "$@" -d "$from" "$to" "$log"
- date
- echo "$@"
- time "$@"
- sleep $sleep
- date | tee -a "$log.loop"
- diff -pu "$log.bak" "$log" | tee -a "$log.loop"
- cp "$log" "$log.bak"
- firstrun=
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement