Files
rettedpv/rettedpv.sh
2025-07-10 14:34:02 +02:00

42 lines
1.0 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
cd /home/oberkoetter/Dokumente/Git/rettedpv
# === Konfiguration ===
REMOTE="ptv-nextcloud:/DPV"
BACKUP_DIR="./Backup"
ARCHIVE_BASE="./Archiv"
LOGFILE="log.txt"
# === Zeitstempel & Archivverzeichnis ===
TIMESTAMP=$(date +%Y-%m-%d-%H-%M)
ARCHIVE_DIR="${ARCHIVE_BASE}/${TIMESTAMP}"
mkdir -p "$ARCHIVE_DIR"
# === Logging-Funktion ===
log() {
echo "$(date '+%Y-%m-%d %H:%M:%S') $1" >> "$LOGFILE"
echo "-> $1"
}
# === Beginn der Sicherung ===
log ""
log ""
log "🔁 Starte Datensicherung…"
# === Synchronisierung mit rclone ===
gum spin --title "rclone läuft..." -- rclone sync "$REMOTE" "$BACKUP_DIR" \
--backup-dir="$ARCHIVE_DIR" \
--log-file="$LOGFILE" \
--log-level=INFO
log " ERR nach rclone: $?"
# === Aufräumen leerer Archivverzeichnisse ===
log "🧹 Entferne leere Verzeichnisse in $ARCHIVE_BASE"
find "$ARCHIVE_BASE" -type d -empty -delete
# === Ende der Sicherung ===
log "✅ Datensicherung abgeschlossen."
gum style --border normal --margin "1" --padding "1 2" --foreground 212 "✅ Backup abgeschlossen!"