Block Level Clone of HDD

I am attempting to pull this info into a script that would prompt the individual running it for details. Info such as the name of the output name, credentials used to mount network shares, selection of the drive which will be cloned.

Below are steps that work, wondering if I can build a script around this to simplify my task.

#Make Mount Location
sudo mkdir /mnt/backup-folder

#Mount Network Share (in this case its a windows file share)
sudo mount -t cifs -o username=jermsmit // /mnt/backup/

#Validate Mount of Share
ls /mnt/backup

#Use fdisk to display disk device to be cloned
# example /dev/sda
sudo fdisk -l

#Clone and Provide MD5 has of Disk
#We change into root with the sudo -i command: 
sudo -i
#We issue the following command replacing 'pc1' with a friendly name
pv < /dev/sda | tee /mnt/backup/pc1.img | md5sum > /mnt/backup/pc1.md5

Why block-level vs file-level clone?

Block-level clones are beneficial because they copy all recognized files, in addition to those that have been deleted, corrupted, from the original disk and filesystem. If you have inadvertently deleted an important file and do not have a file recovery tool, using a cloning program to immediately create a block-level clone will increase your chances of recovering the file since it lessens the chance that the file’s data blocks will be overwritten.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.