fix: Backups

This commit is contained in:
Kroese 2025-09-17 22:48:30 +02:00 committed by GitHub
parent ceaacaeb2c
commit 49090dcbc4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,20 +9,29 @@ backup () {
local count=1 local count=1
local iso="$1" local iso="$1"
local name="$2" local folder="unknown"
local folder="$name" local root="$STORAGE/backups"
local dir="$STORAGE/backups" local previous="$STORAGE/windows.base"
mkdir -p "$dir" if [ -f "$previous" ]; then
while [ -d "$dir/$folder" ] previous=$(<"$previous")
previous="${previous//[![:print:]]/}"
[ -n "$previous" ] && folder="${previous%.*}"
fi
mkdir -p "$root"
local dir="$root/$folder"
while [ -d "$dir" ]
do do
count=$[$count +1] count=$[$count +1]
folder="${name}.${count}" folder="${folder%.*}.${count}"
dir="$root/$folder"
done done
dir+="/$folder"
rm -rf "$dir" rm -rf "$dir"
mkdir -p "$dir" mkdir -p "$dir"
@ -32,6 +41,8 @@ backup () {
find "$STORAGE" -maxdepth 1 -type f \( -iname '*.rom' -or -iname '*.vars' \) -exec mv -n {} "$dir/" \; find "$STORAGE" -maxdepth 1 -type f \( -iname '*.rom' -or -iname '*.vars' \) -exec mv -n {} "$dir/" \;
[ -z "$(ls -A "$dir")" ] && rm -rf "$dir" [ -z "$(ls -A "$dir")" ] && rm -rf "$dir"
[ -z "$(ls -A "$root")" ] && rm -rf "$root"
return 0 return 0
} }
@ -75,7 +86,7 @@ skipInstall() {
fi fi
info "Detected that $method, a backup of your previous installation will be saved..." info "Detected that $method, a backup of your previous installation will be saved..."
! backup "$STORAGE/$previous" "${previous%.*}" && error "Backup failed!" ! backup "$STORAGE/$previous" && error "Backup failed!"
return 1 return 1
@ -140,7 +151,7 @@ startInstall() {
skipInstall "$BOOT" && return 1 skipInstall "$BOOT" && return 1
if hasDisk; then if hasDisk; then
! backup "" "backup" && error "Backup failed!" ! backup "" && error "Backup failed!"
fi fi
mkdir -p "$TMP" mkdir -p "$TMP"