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

31 lines
1021 B
Bash
Raw Normal View History

2020-05-02 11:46:39 +02:00
#!/bin/bash
2020-05-19 11:10:06 +02:00
# shellcheck disable=SC2010 # ls | grep allowed
2020-05-06 09:25:53 +02:00
# shellcheck disable=SC2015 # Deactivating bool hint
2020-05-15 12:00:03 +02:00
# shellcheck source=/dev/null # Deactivate SC1090
2020-05-19 11:10:06 +02:00
# shellcheck disable=SC2154 # Deactivate not referenced link
# shellcheck disable=SC2015 # Deactivate bools hints
2020-05-15 12:00:03 +02:00
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
2020-05-15 14:10:24 +02:00
set_device_path
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-15 14:10:24 +02:00
info "Input file: $device_path"
2020-05-03 20:58:23 +02:00
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..." &&
2020-05-15 14:10:24 +02:00
dd if="$device_path" of="$ofi" bs=1M status=progress || error "\"dd\" failed.";
2020-05-06 09:25:53 +02:00
success "Imagetransfer successfull." && exit 0;