Compare commits
4
Commits
main
...
9282284472
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9282284472 | ||
|
|
049f3aed84 | ||
|
|
c64be0e9fa | ||
|
|
788c9f07b9 |
No files matched your search
@@ -0,0 +1,73 @@
|
||||
#!/bin/bash
|
||||
# This script runs the index process of PhotoPrism.
|
||||
# it must be called from a cronjob or similar to ensure it runs periodically.
|
||||
|
||||
# Flag-Datei zur Vermeidung paralleler Ausführungen
|
||||
FLAG_FILE="/root/photoprism-auto-index.flag"
|
||||
LOG_FILE="/root/photoprism-auto-index.log"
|
||||
MAX_LOG_SIZE=$((10 * 1024 * 1024)) # 10 MB in Bytes
|
||||
MAX_FLAG_AGE=$((12 * 60 * 60)) # 12 Stunden in Sekunden
|
||||
|
||||
# Log-Funktion
|
||||
log() {
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" >> "$LOG_FILE"
|
||||
|
||||
# Prüfe Log-Größe und kürze wenn nötig
|
||||
if [ -f "$LOG_FILE" ]; then
|
||||
LOG_SIZE=$(stat -f %z "$LOG_FILE" 2>/dev/null || echo 0)
|
||||
if [ "$LOG_SIZE" -gt "$MAX_LOG_SIZE" ]; then
|
||||
# Behalte nur die letzten 50% des Logs
|
||||
tail -n 5000 "$LOG_FILE" > "$LOG_FILE.tmp"
|
||||
mv "$LOG_FILE.tmp" "$LOG_FILE"
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') - Log gekürzt (war $((LOG_SIZE / 1024 / 1024)) MB)" >> "$LOG_FILE"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Cleanup-Funktion die IMMER ausgeführt wird (auch bei Fehlern/Abbruch)
|
||||
cleanup() {
|
||||
rm -f "$FLAG_FILE"
|
||||
log "Cleanup: Flag-Datei gelöscht"
|
||||
}
|
||||
|
||||
# trap registriert die cleanup-Funktion für verschiedene Exit-Szenarien:
|
||||
# EXIT = normales Script-Ende
|
||||
# INT = CTRL+C (Signal 2)
|
||||
# TERM = kill-Befehl (Signal 15)
|
||||
# ERR = wenn ein Befehl fehlschlägt (bei set -e)
|
||||
trap cleanup EXIT INT TERM ERR
|
||||
|
||||
log "Script gestartet (PID: $$)"
|
||||
|
||||
# Prüfe ob ein anderer Prozess bereits läuft
|
||||
if [ -f "$FLAG_FILE" ]; then
|
||||
# Prüfe Alter der Flag-Datei
|
||||
FLAG_MTIME=$(stat -f %m "$FLAG_FILE" 2>/dev/null || echo 0)
|
||||
CURRENT_TIME=$(date +%s)
|
||||
FLAG_AGE=$((CURRENT_TIME - FLAG_MTIME))
|
||||
|
||||
if [ $FLAG_AGE -gt $MAX_FLAG_AGE ]; then
|
||||
log "Flag-Datei ist älter als 12h ($((FLAG_AGE / 3600))h) - lösche sie und starte neu"
|
||||
cleanup
|
||||
else
|
||||
log "Abbruch: Prozess läuft bereits (seit $((FLAG_AGE / 60)) Minuten)"
|
||||
trap - EXIT INT TERM ERR
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
log "Erstelle Flag-Datei"
|
||||
echo "Started: $(date '+%Y-%m-%d %H:%M:%S') | PID: $$" > "$FLAG_FILE"
|
||||
|
||||
# Führe Index-Prozess aus
|
||||
log "Starte PhotoPrism Index-Prozess"
|
||||
docker exec ix-photoprism-photoprism-1 photoprism index >> "$LOG_FILE" 2>&1
|
||||
EXIT_CODE=$?
|
||||
|
||||
if [ $EXIT_CODE -eq 0 ]; then
|
||||
log "Index-Prozess erfolgreich abgeschlossen"
|
||||
else
|
||||
log "Index-Prozess fehlgeschlagen (Exit-Code: $EXIT_CODE)"
|
||||
fi
|
||||
|
||||
# Flag-Datei wird automatisch durch trap cleanup gelöscht
|
||||
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
<string>com.backup-recordings-to-bfds</string>
|
||||
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>/bin/bash</string>
|
||||
<string>/Users/rob/code/lokale-scripte/macos/Backup-Recordings/backup-recordings-to-bfds.sh</string>
|
||||
</array>
|
||||
|
||||
<key>StartCalendarInterval</key>
|
||||
<dict>
|
||||
<key>Hour</key>
|
||||
<integer>12</integer>
|
||||
<key>Minute</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
|
||||
<key>StandardOutPath</key>
|
||||
<string>/Users/rob/code/lokale-scripte/macos/Backup-Recordings/run-backup-recordings_output.log</string>
|
||||
<key>StandardErrorPath</key>
|
||||
<string>/Users/rob/code/lokale-scripte/macos/Backup-Recordings/run-backup-recordings_error.log</string>
|
||||
|
||||
<key>RunAtLoad</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Quelle und Ziel definieren
|
||||
SOURCE="/Users/rob/Recordings/Work/"
|
||||
TARGET="/Volumes/rob/recordings/Progress/Work/"
|
||||
MOUNT_POINT="/Volumes/rob"
|
||||
SERVER_ADDRESS="smb://bfds/rob"
|
||||
|
||||
# Prüfen, ob das Netzlaufwerk gemountet ist
|
||||
if mount | grep -q "$MOUNT_POINT"; then
|
||||
echo "Netzlaufwerk ist gemountet. Backup startet..."
|
||||
else
|
||||
echo "Netzlaufwerk nicht gefunden. Versuche zu mounten..."
|
||||
osascript -e "mount volume \"$SERVER_ADDRESS\""
|
||||
|
||||
# Nach dem Mounten erneut prüfen
|
||||
if mount | grep -q "$MOUNT_POINT"; then
|
||||
echo "Netzlaufwerk erfolgreich gemountet."
|
||||
else
|
||||
echo "Fehler: Netzlaufwerk konnte nicht gemountet werden."
|
||||
osascript -e 'display notification "Backup fehlgeschlagen! Netzlaufwerk nicht erreichbar." with title "Backup Script"'
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Sicherung starten
|
||||
rsync -v -r -l -t -D "$SOURCE" "$TARGET"
|
||||
|
||||
# -r → Rekursiv kopieren (alle Unterordner & Dateien)
|
||||
# -l → Symbolische Links kopieren
|
||||
# -t → Zeitstempel beibehalten
|
||||
# -D → Geräte- und Sonderdateien kopiere
|
||||
|
||||
# Erfolgsmeldung ausgeben
|
||||
echo "Backup abgeschlossen: $DATE"
|
||||
|
||||
# Optional: Notification für macOS anzeigen
|
||||
osascript -e 'display notification "Backup abgeschlossen!" with title "Backup Script"'
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
Transfer starting: 2080 files
|
||||
./00_MacOS/ErsterGitarrenTest/.DS_Store
|
||||
./00_MacOS/Mobile Beats/.DS_Store
|
||||
./00_MacOS/ReaperOnLinuxErsterTestt/.DS_Store
|
||||
./00_MacOS/Vielleicht mal ein RMB Song/.DS_Store
|
||||
rsync: mkstemp "/Volumes/rob/recordings/Progress/Work/00_MacOS/ErsterGitarrenTest/..DS_Store.bvPX7I" failed: Operation not permitted (1)
|
||||
rsync: mkstemp "/Volumes/rob/recordings/Progress/Work/00_MacOS/Mobile Beats/..DS_Store.3IHOo3" failed: Operation not permitted (1)
|
||||
rsync: failed to set times on "/Volumes/rob/recordings/Progress/Work/02_Windows/After Work - NY Video": Operation not permitted (1)
|
||||
./00_MacOS/dance the break/.DS_Store
|
||||
./01_Linux/DumDrumsV1/.DS_Store
|
||||
./01_Linux/Maschienenraum/.DS_Store
|
||||
./01_Linux/VN9J6C~K/.DS_Store
|
||||
./01_Linux/YoutubeNachbauen/.DS_Store
|
||||
rsync: mkstemp "/Volumes/rob/recordings/Progress/Work/00_MacOS/ReaperOnLinuxErsterTestt/..DS_Store.HZfDuM" failed: Operation not permitted (1)
|
||||
./02_Windows/LMMS/.DS_Store
|
||||
./02_Windows/MCSequencer-FirstTest/.DS_Store
|
||||
rsync: mkstemp "/Volumes/rob/recordings/Progress/Work/00_MacOS/Vielleicht mal ein RMB Song/..DS_Store.ROkSo0" failed: Operation not permitted (1)
|
||||
rsync: mkstemp "/Volumes/rob/recordings/Progress/Work/00_MacOS/dance the break/..DS_Store.aFBtuQ" failed: Operation not permitted (1)
|
||||
rsync: failed to set times on "/Volumes/rob/recordings/Progress/Work/02_Windows/WakeMeUp": Operation not permitted (1)
|
||||
rsync: mkstemp "/Volumes/rob/recordings/Progress/Work/01_Linux/DumDrumsV1/..DS_Store.yWjLTm" failed: Operation not permitted (1)
|
||||
./03_LMMS/plugins/.DS_Store
|
||||
./05_Midi/Groove Monkee Free MIDI GM/.DS_Store
|
||||
rsync: mkstemp "/Volumes/rob/recordings/Progress/Work/01_Linux/Maschienenraum/..DS_Store.lnwOWK" failed: Operation not permitted (1)
|
||||
rsync: mkstemp "/Volumes/rob/recordings/Progress/Work/01_Linux/VN9J6C~K/..DS_Store.q9CbtG" failed: Operation not permitted (1)
|
||||
rsync: mkstemp "/Volumes/rob/recordings/Progress/Work/01_Linux/YoutubeNachbauen/..DS_Store.JnjLUb" failed: Operation not permitted (1)
|
||||
rsync: mkstemp "/Volumes/rob/recordings/Progress/Work/02_Windows/LMMS/..DS_Store.iWwhBB" failed: Operation not permitted (1)
|
||||
rsync: mkstemp "/Volumes/rob/recordings/Progress/Work/02_Windows/MCSequencer-FirstTest/..DS_Store.kuF708" failed: Operation not permitted (1)
|
||||
rsync: mkstemp "/Volumes/rob/recordings/Progress/Work/03_LMMS/plugins/..DS_Store.GF6pRJ" failed: Operation not permitted (1)
|
||||
rsync: mkstemp "/Volumes/rob/recordings/Progress/Work/05_Midi/Groove Monkee Free MIDI GM/..DS_Store.UerlTC" failed: Operation not permitted (1)
|
||||
|
||||
sent 258314 bytes received 318 bytes 7085 bytes/sec
|
||||
total size is 646892330 speedup is 2501.21
|
||||
rsync: failed to set times on "/Volumes/rob/recordings/Progress/Work/02_Windows/After Work - NY Video": Operation not permitted (1)
|
||||
rsync: failed to set times on "/Volumes/rob/recordings/Progress/Work/02_Windows/WakeMeUp": Operation not permitted (1)
|
||||
@@ -0,0 +1,2 @@
|
||||
Netzlaufwerk ist gemountet. Backup startet...
|
||||
Backup abgeschlossen:
|
||||
@@ -0,0 +1,13 @@
|
||||
Die *.plist datei definiert wann immer das cript startet (12Uhr täglich)
|
||||
|
||||
Die Befehle um das script in LaunchAgents einzufügen:
|
||||
|
||||
# Im Terminal benutzen
|
||||
|
||||
- wenn $(id -u) fehler wirft den aktuellen user id manuell eingeben. sollte 501 sein
|
||||
- bootout löscht erstmal das alte zeug und bootstrap fügt es neu hinzu.
|
||||
|
||||
```
|
||||
launchctl bootout gui/$(id -u) ~/Library/LaunchAgents/com.backup-recordings-to-bfds.plist
|
||||
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.backup-recordings-to-bfds.plist
|
||||
```
|
||||
Reference in new issue
Block a user