~cyplo/dotfiles

ref: 1ca69547b9a678da7a89ac93b7822ac478a2ab7d dotfiles/tools/backup_sdcard -rwxr-xr-x 347 bytes
1ca69547 — Cyryl Płotnicki update 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash

if [[ -z $1 ]]; then
    echo "usage: $0 device_to_clone"
    exit
fi

device=$1

timestamp=`date +%Y%m%d`
dest_file="/tmp/$timestamp.dd.xz"

echo "about to clone $device to $dest_file"
echo "ctrl-c or [enter]"
read

sudo umount $device?
sudo umount $device

sudo sync
sudo pv -tpreb $device | dd bs=4M | pixz > $dest_file
sudo sync