2014-10-11 10:25:24 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [[ -z $1 ]]; then
|
|
|
|
echo "usage: $0 device_to_clone"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
device=$1
|
|
|
|
|
2014-10-25 11:31:25 +01:00
|
|
|
timestamp=`date +%Y%m%d`
|
2014-10-11 10:25:24 +01:00
|
|
|
dest_file="/tmp/$timestamp.dd.xz"
|
|
|
|
|
|
|
|
echo "about to clone $device to $dest_file"
|
|
|
|
echo "ctrl-c or [enter]"
|
|
|
|
read
|
|
|
|
|
2015-02-14 07:25:34 +00:00
|
|
|
sudo umount $device?
|
|
|
|
sudo umount $device
|
2014-10-11 10:25:24 +01:00
|
|
|
|
2015-02-14 07:33:03 +00:00
|
|
|
sudo sync
|
2014-10-11 10:25:24 +01:00
|
|
|
sudo pv -tpreb $device | dd bs=4M | pixz > $dest_file
|
2015-02-14 07:25:34 +00:00
|
|
|
sudo sync
|
2014-10-11 10:25:24 +01:00
|
|
|
|