From 93b2dc85a6f2d691d2fb3db223449e86168784d3 Mon Sep 17 00:00:00 2001 From: Cyryl Plotnicki-Chudyk Date: Sat, 14 Feb 2015 08:25:34 +0100 Subject: [PATCH] added a script to restor sdcards from files --- tools/backup_sdcard | 5 +++-- tools/restore_sdcard | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100755 tools/restore_sdcard diff --git a/tools/backup_sdcard b/tools/backup_sdcard index a3b127c2..bc4f4aa0 100755 --- a/tools/backup_sdcard +++ b/tools/backup_sdcard @@ -14,8 +14,9 @@ echo "about to clone $device to $dest_file" echo "ctrl-c or [enter]" read -umount $device? -umount $device +sudo umount $device? +sudo umount $device sudo pv -tpreb $device | dd bs=4M | pixz > $dest_file +sudo sync diff --git a/tools/restore_sdcard b/tools/restore_sdcard new file mode 100755 index 00000000..adfc7138 --- /dev/null +++ b/tools/restore_sdcard @@ -0,0 +1,27 @@ +#!/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 +timestamp=`date +%Y%m%d` + +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 +