overhaul toast and log messages
This commit is contained in:
1 parent
61a92128a6
commit
eeac807158
1 file changed
+27
-8
@@ -23,11 +23,18 @@ log() {
|
||||
echo "$message" | tee -a "$LOGFILE"
|
||||
}
|
||||
|
||||
# Funktion für macOS Benachrichtigungen
|
||||
notify() {
|
||||
local subtitle="$1"
|
||||
local message="$2"
|
||||
osascript -e "display notification \"$message\" with title \"Backup Recordings\" subtitle \"$subtitle\""
|
||||
}
|
||||
|
||||
# Log rotieren falls nötig
|
||||
rotate_log
|
||||
|
||||
# Quelle und Ziel definieren
|
||||
SOURCE="/Users/rob/Recordings/Work/"
|
||||
SOURCE="/Users/rob/Recordings/Work/00_MacOS"
|
||||
TARGET="/Volumes/rob/recordings/Progress/Work/"
|
||||
MOUNT_POINT="/Volumes/rob"
|
||||
SERVER_ADDRESS="smb://bfds/rob"
|
||||
@@ -44,23 +51,35 @@ else
|
||||
log "Netzlaufwerk erfolgreich gemountet."
|
||||
else
|
||||
log "Fehler: Netzlaufwerk konnte nicht gemountet werden."
|
||||
osascript -e 'display notification "Backup fehlgeschlagen! Netzlaufwerk nicht erreichbar." with title "Backup Script"'
|
||||
notify "Fehler" "Server nicht erreichbar!\nRecordings -> BFDS"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Sicherung starten
|
||||
rsync -v -r -l -t -D "$SOURCE" "$TARGET"
|
||||
log "Starte rsync..."
|
||||
RSYNC_OUTPUT=$(mktemp)
|
||||
rsync -v -r -l -t -D --stats "$SOURCE" "$TARGET" 2>&1 | tee -a "$LOGFILE" > "$RSYNC_OUTPUT"
|
||||
|
||||
# -r → Rekursiv kopieren (alle Unterordner & Dateien)
|
||||
# -l → Symbolische Links kopieren
|
||||
# -t → Zeitstempel beibehalten
|
||||
# -D → Geräte- und Sonderdateien kopiere
|
||||
# -D → Geräte- und Sonderdateien kopieren
|
||||
# --stats → Statistiken anzeigen
|
||||
|
||||
# Statistiken auslesen
|
||||
TOTAL_FILES=$(grep "Number of regular files transferred:" "$RSYNC_OUTPUT" | awk '{print $6}' | tr -d ',')
|
||||
TOTAL_SIZE=$(grep "Total transferred file size:" "$RSYNC_OUTPUT" | awk '{print $5, $6}')
|
||||
|
||||
# Fallback falls keine Werte gefunden wurden
|
||||
[ -z "$TOTAL_FILES" ] && TOTAL_FILES="0"
|
||||
[ -z "$TOTAL_SIZE" ] && TOTAL_SIZE="0 bytes"
|
||||
|
||||
# Temporäre Datei löschen
|
||||
rm -f "$RSYNC_OUTPUT"
|
||||
|
||||
# Erfolgsmeldung ausgeben
|
||||
log "Backup abgeschlossen"
|
||||
log "Backup abgeschlossen: $TOTAL_FILES Dateien, $TOTAL_SIZE übertragen"
|
||||
|
||||
# Optional: Notification für macOS anzeigen
|
||||
osascript -e 'display notification "Backup abgeschlossen!" with title "Backup Script"'
|
||||
|
||||
|
||||
notify "Abgeschlossen" "$TOTAL_FILES Dateien übertragen ($TOTAL_SIZE)"
|
||||
Reference in new issue
Block a user