feat: Lösch-Synchronisation mit lokalem Backup und Bereinigung

Gelöschte Dateien werden beim Download ins Backup-Verzeichnis verschoben
(${LOCAL_PHOTO_DIR}-bak, ${LOCAL_DARKTABLE_DB_DIR}-bak) statt permanent
gelöscht. Upload verwendet --delete ohne Backup. Backups älter als 2 Jahre
werden automatisch bereinigt. Safeguard verhindert --delete bei leerem
Quellverzeichnis. validate_path prüft jetzt auch lokale Pfade.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-21 07:04:06 +02:00
parent d714f95cb7
commit faa65dde2f
7 changed files with 166 additions and 9 deletions
+14
View File
@@ -59,6 +59,8 @@ validate_config() {
validate_path SERVER_DB_DIR
validate_path SERVER_PHOTO_DIR
validate_path LOCAL_DARKTABLE_DB_DIR
validate_path LOCAL_PHOTO_DIR
# DARKTABLE_BIN: basename muss 'darktable' sein
if [[ "$(basename "$DARKTABLE_BIN")" != "darktable" ]]; then
@@ -127,6 +129,18 @@ gelöscht:^\*deleting
EOF
}
cleanup_old_backups() {
local backup_dir="$1"
[ -d "$backup_dir" ] || return 0
local count
count=$(find "$backup_dir" -type f -mtime +730 | wc -l)
if [ "$count" -gt 0 ]; then
log "Backup-Bereinigung: $count Datei(en) älter als 2 Jahre in $backup_dir"
find "$backup_dir" -type f -mtime +730 -delete
find "$backup_dir" -type d -empty -delete 2>/dev/null || true
fi
}
confirm_dry_run() {
[ "${DRY_RUN_SKIP_CONFIRM:-0}" = "1" ] && return 0
ask_user "Darktable Sync Trockenlauf" \