Set a consistent set of variables across most *nix systems so the capture and restore commands are unified.
# Set the target disk
DISK='/dev/sdb';
# Get disk size
fdisk -l | grep $DISK;
# Set the disk size
DISKSIZE='146810536448';
# Set the target disk
DISK='/dev/da1';
# Get disk size
diskinfo -v $DISK;
# Set the disk size
DISKSIZE='146810536448';
# Set the target disk
D='c2t2d0';
# slice 2 is the entire disk.
DISK='/dev/dsk/'$D's2';
# Get disk size
iostat -En $D | grep bytes
# Set the disk size
DISKSIZE='146810536448'
pv -p -e -a -b -s $DISKSIZE $DISK | pigz -1 > /mnt/repo/disk.img.gz
Note: replace pigz -1
with a level of compression that works well for your situation. eg: pigz -9
for best compression.
This method seems faster than method 2.
pigz -dc /mnt/repo/disk.img.gz | pv -a -p -e -b -s $DISKSIZE > $DISK
This method offers more contol over method 1.
pigz -dc /mnt/repo/disk.img.gz | pv -a -p -e -b -s $DISKSIZE | dd of=$DISK bs=4194304