On the BTRFS mailing list one of the devs (or smart engineers) posted a different gddrescue script to clone brtfs drives, that should allow for better clones in times of troubles. It supposed to work better with drives that contain a BTRFS filesystem

TYPICAL gDDRESCUE
From the gddrescue manpage (man page # man ddrescue) the simplest way is to first copy the good sections and then clone the bad sections. It copies only the bad sections on the second try because the log file keeps track of the progress (and it wont copy an area it successfuly copied already). ThereforeAfter ddrescue -n the destination drive DST123 will have all of the good sectors of the source drive SRC123. Now The logfile will mention all of these good and bad sectors so that when ddrescue -r1 runs it only runs across the none copied sectors (thats what it does, it will only attempt on none attempted sectors, and since -n says do not attempt bad sectors, all we have left then is just bad sectors) which are bad. It will retry once on them. If you want more retries just increase the count from -r1 to -r2 to -r3 (or whatever you want)

#!/bin/bash
SRC123=/dev/sda
DST123=/dev/sdb
LOG123=/root/loga2b
ddrescue -n ${SRC123} ${DST123} ${LOG123}
ddrescue -r1 ${SRC123} ${DST123} ${LOG123}

If need to force it:

#!/bin/bash
SRC123=/dev/sda
DST123=/dev/sdb
LOG123=/root/loga2b
ddrescue -f -n ${SRC123} ${DST123} ${LOG123}
ddrescue  -f -r1 ${SRC123} ${DST123} ${LOG123}

Or one that logs to text file and to ddlog file (the text file can be viewed at any time to see if its on the first or second ddrescue command)

#!/bin/bash
# --------- #
# need gddrescue (which gives the command ddrescue)
# clone script, just fill out variables
# make sure clone disks are not used
# LOG123 is for ddrescue log
# LOGTXT123 is for text logs
# Force variable (if you dont use it, it might complain that drives arent correct format, and that you must use -f to continue)
############ variables ##############
SRC123=/dev/hdc
DST123=/dev/hdi
LOG123="/root/clone.ddlog"
LOGTXT123="/root/clonelog.txt"
############ force variable ##############
FORCE123="-f"
# if dont need force then comment out above and uncomment below
# FORCE123=" "
##########################
echo "[`date`][`date +%s`] =============================== 1/2 ddrescue -n ${FORCE123} ${SRC123} ${DST123} ${LOG123}"
ddrescue -n ${FORCE123} ${SRC123} ${DST123} ${LOG123}
echo "[`date`][`date +%s`] =============================== 2/2 ddrescue -r1 ${FORCE123} ${SRC123} ${DST123} ${LOG123}"
ddrescue -r2 ${FORCE123} ${SRC123} ${DST123} ${LOG123}
echo "[`date`][`date +%s`] =============================== DONE!"

 

TWEAKED gDDRESCUE 4 BTRFS DISKS

Link: http://www.spinics.net/lists/linux-btrfs/msg33168.html

Here is their script (just change the variables)

#!/bin/bash
src_disk=/dev/disk/by-id/ata-ST3250410AS_6RYF5NP7
dst_disk=/dev/disk/by-id/ata-ST3500418AS_9VM2ZZQS
#log=/path/to/log
log=~/brendan-laptop.recovery.log

#Sector size (default is 512 - newer disks should probably be 4096)
sector_size=4096

#Force writing to a block device - disable if you're backing up to an image file #force=""
force="-f"

# We want to skip bigger chunks to get as much data as possible before the source disk really dies # For the same reason, we also want to start with (attempting) to maintain a high read rate #Minimum read rate in MB/s before skipping
min_readrate=10485760

#Default skip size is 64k.
for skip_size in 65536 16384; do
#Going forward
ddrescue -r 1 -a $min_readrate -b $sector_size -d $force -K $skip_size $src_disk $dst_disk $log
#Going in reverse
ddrescue -r 1 -a $min_readrate -b $sector_size -d $force -K $skip_size -R $src_disk $dst_disk $log
done

#Default skip size is 64k.
#This time re-trying all failed/skipped sections
for skip_size in 4096; do
#Going forward
ddrescue -r 1 -a $min_readrate -b $sector_size -d $force -K $skip_size -A $src_disk $dst_disk $log
#Going in reverse
ddrescue -r 1 -a $min_readrate -b $sector_size -d $force -K $skip_size -R -A $src_disk $dst_disk $log
done

#Default skip size is 64k.
for skip_size in 1024 256 64 ; do
#Going forward
ddrescue -r 1 -b $sector_size -d $force -K $skip_size $src_disk $dst_disk $log
#Going in reverse
ddrescue -r 1 -b $sector_size -d $force -K $skip_size -R $src_disk $dst_disk $log
done

echo "Done. Run an chkdsk/fsck/whatever-might-be appropriate for the new disk's filesystem(s)"

 

Leave a Reply

Your email address will not be published. Required fields are marked *