1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00

fix-sd: backup corrupt files to pwd

This commit is contained in:
2024-10-05 14:53:59 +02:00
parent 5ba3dfc451
commit 4774a0ec0f

View File

@@ -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