~cyplo/dotfiles

ref: 83ddcc09dc68389b129d598722eca9e90a6dff33 dotfiles/tools/restore_sdcard -rwxr-xr-x 441 bytes
83ddcc09 — Cyryl Płotnicki remove broken i3 msg call 1 year, 10 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
24
25
26
#!/bin/bash

if [[ -z $1 ]] || [[ -z $2 ]]; then
    echo "usage: $0 restore_file.xz device_to_restore_to"
    exit
fi

source_file=$1
if [[ ! -f $source_file ]]; then
    echo "cannot open $source_file"
    exit
fi

device=$2

echo "about to restore $source_file onto $device"
echo "ctrl-c or [enter]"
read

sudo umount $device?
sudo umount $device

pv -tpreb $source_file | pixz -d | sudo dd bs=4M of=$device
sudo sync
sudo eject $device