linux-image-manager/scripts/image/backup.sh

39 lines
1.0 KiB
Bash
Raw Normal View History

2020-05-02 11:46:39 +02:00
#!/bin/bash
2020-05-06 09:25:53 +02:00
# shellcheck disable=SC2010
# shellcheck disable=SC2015 # Deactivating bool hint
2020-05-15 12:00:03 +02:00
# shellcheck source=/dev/null # Deactivate SC1090
source "$(dirname "$(readlink -f "${0}")")/base.sh" || (echo "Loading base.sh failed." && exit 1)
2020-05-06 09:25:53 +02:00
info "Backupscript for memory devices started..."
2020-05-03 20:58:23 +02:00
echo
info "Actual mounted devices:"
echo
ls -lasi /dev/ | grep -E "sd|mm"
2020-05-02 11:46:39 +02:00
echo
2020-05-06 08:59:48 +02:00
while [ ! -b "$ifi" ]
2020-05-02 11:46:39 +02:00
do
2020-05-03 20:58:23 +02:00
info "Please select the correct device."
question "/dev/:"
2020-05-06 08:59:48 +02:00
read -r device
2020-05-03 20:58:23 +02:00
ifi="/dev/$device"
done
2020-05-02 11:46:39 +02:00
while [ "$path" == "" ]
do
2020-05-05 11:50:20 +02:00
echo "Bitte Backupimagepfad+Namen zu $PWD eingeben:"
read -r path
2020-05-02 11:46:39 +02:00
if [ "${path:0:1}" == "/" ]
then
2020-05-05 11:50:20 +02:00
ofi="$path.img"
2020-05-02 11:46:39 +02:00
else
2020-05-05 11:50:20 +02:00
ofi="$PWD/$path.img"
2020-05-02 11:46:39 +02:00
fi
done
2020-05-03 20:58:23 +02:00
info "Input file: $ifi"
info "Output file: $ofi"
question "Please confirm by pushing \"Enter\". To cancel use \"Ctrl + Alt + C\""
2020-05-06 09:25:53 +02:00
read -r bestaetigung && echo "$bestaetigung";
info "Imagetransfer starts. This can take a while..." &&
dd if="$ifi" of="$ofi" bs=1M status=progress || error "\"dd\" failed.";
success "Imagetransfer successfull." && exit 0;