mirror of
https://github.com/kmein/niveum
synced 2026-03-16 10:11:08 +01:00
22 lines
472 B
Bash
Executable File
22 lines
472 B
Bash
Executable File
#!/bin/sh
|
|
set -xfu
|
|
|
|
drive="$1"
|
|
mountpoint="/media/sd-card-$(date +%s)"
|
|
backup_directory="$(pwd)"
|
|
|
|
trap clean EXIT
|
|
clean() {
|
|
umount "$mountpoint"
|
|
rmdir "$mountpoint"
|
|
fsck.exfat "$drive"
|
|
}
|
|
|
|
filenames="$(fsck.exfat "$drive" 2>&1 | sed -nE "s/.* file '(.*?)' is not allocated.*/\1/p")"
|
|
mkdir "$mountpoint"
|
|
mount "$drive" "$mountpoint"
|
|
|
|
echo "$filenames" | while read -r filename; do
|
|
find "$mountpoint" -type f -name "$filename" -exec mv {} "$backup_directory" \;
|
|
done
|