From 4774a0ec0f45b01e3875f8bacc0b5d0108504ae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Sat, 5 Oct 2024 14:53:59 +0200 Subject: [PATCH] fix-sd: backup corrupt files to pwd --- .bin/fix-sd.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.bin/fix-sd.sh b/.bin/fix-sd.sh index e36202b..0a24fa9 100755 --- a/.bin/fix-sd.sh +++ b/.bin/fix-sd.sh @@ -1,7 +1,9 @@ #!/bin/sh +set -xfu drive="$1" mountpoint="/media/sd-card-$(date +%s)" +backup_directory="$(pwd)" trap clean EXIT clean() { @@ -14,6 +16,6 @@ mkdir "$mountpoint" mount "$drive" "$mountpoint" echo "$filenames" | while read -r filename; do - find "$mountpoint" -type f -name "$filename" -exec rm {} \; + find "$mountpoint" -type f -name "$filename" -exec mv {} "$backup_directory" \; done