Fix sync script

This commit is contained in:
yves-sbb committed 2026-09-28 19:57:51 +02:00
1 parent 568806e7f9
commit 6d4e3c708e
2 files changed
+153 -15

No files matched your search

+126
View File
@@ -91,3 +91,129 @@
[2026-09-28 19:48:28] Modus: status
[2026-09-28 19:48:28] ═══════════════════════════════════════════════════════════
[2026-09-28 19:48:28] Status: Vergleiche Repo mit Home-Dir...
[2026-09-28 19:49:48] ═══════════════════════════════════════════════════════════
[2026-09-28 19:49:48] Modus: status
[2026-09-28 19:49:48] ═══════════════════════════════════════════════════════════
[2026-09-28 19:49:48] Status: Vergleiche Repo mit Home-Dir...
[2026-09-28 19:50:35] ═══════════════════════════════════════════════════════════
[2026-09-28 19:50:35] Modus: status
[2026-09-28 19:50:35] ═══════════════════════════════════════════════════════════
[2026-09-28 19:50:35] Status: Vergleiche Repo mit Home-Dir...
[2026-09-28 19:51:40] ═══════════════════════════════════════════════════════════
[2026-09-28 19:51:40] Modus: status
[2026-09-28 19:51:40] ═══════════════════════════════════════════════════════════
[2026-09-28 19:51:40] Status: Vergleiche Repo mit Home-Dir...
[DEBUG] ✓ identisch: .bash_aliases
[2026-09-28 19:51:53] ═══════════════════════════════════════════════════════════
[2026-09-28 19:51:53] Modus: status
[2026-09-28 19:51:53] ═══════════════════════════════════════════════════════════
[2026-09-28 19:51:53] Status: Vergleiche Repo mit Home-Dir...
[2026-09-28 19:52:09] ═══════════════════════════════════════════════════════════
[2026-09-28 19:52:09] Modus: status
[2026-09-28 19:52:09] ═══════════════════════════════════════════════════════════
[2026-09-28 19:52:09] Status: Vergleiche Repo mit Home-Dir...
[2026-09-28 19:52:27] ═══════════════════════════════════════════════════════════
[2026-09-28 19:52:27] Modus: pull
[2026-09-28 19:52:27] DRY-RUN: Keine Änderungen werden vorgenommen
[2026-09-28 19:52:27] ═══════════════════════════════════════════════════════════
[2026-09-28 19:52:27] Pull: Synchronisiere geänderte Dateien von Home-Dir ins Repo...
[2026-09-28 19:52:31] ═══════════════════════════════════════════════════════════
[2026-09-28 19:52:31] Modus: push
[2026-09-28 19:52:31] DRY-RUN: Keine Änderungen werden vorgenommen
[2026-09-28 19:52:31] ═══════════════════════════════════════════════════════════
[2026-09-28 19:52:31] Push: Synchronisiere Repo-Dateien ins Home-Dir...
[DEBUG] ⊙ unverändert: .bash_aliases
[2026-09-28 19:52:43] ═══════════════════════════════════════════════════════════
[2026-09-28 19:52:43] Modus: push
[2026-09-28 19:52:43] DRY-RUN: Keine Änderungen werden vorgenommen
[2026-09-28 19:52:43] ═══════════════════════════════════════════════════════════
[2026-09-28 19:52:43] Push: Synchronisiere Repo-Dateien ins Home-Dir...
[DEBUG] ⊙ unverändert: .bash_aliases
[2026-09-28 19:52:58] ═══════════════════════════════════════════════════════════
[2026-09-28 19:52:58] Modus: status
[2026-09-28 19:52:58] ═══════════════════════════════════════════════════════════
[2026-09-28 19:52:58] Status: Vergleiche Repo mit Home-Dir...
[DEBUG] ✓ identisch: .bash_aliases
[2026-09-28 19:53:09] ═══════════════════════════════════════════════════════════
[2026-09-28 19:53:09] Modus: status
[2026-09-28 19:53:09] ═══════════════════════════════════════════════════════════
[2026-09-28 19:53:09] Status: Vergleiche Repo mit Home-Dir...
[2026-09-28 19:53:59] ═══════════════════════════════════════════════════════════
[2026-09-28 19:53:59] Modus: status
[2026-09-28 19:53:59] ═══════════════════════════════════════════════════════════
[2026-09-28 19:53:59] Status: Vergleiche Repo mit Home-Dir...
[DEBUG] ✓ identisch: .bash_aliases
[2026-09-28 19:54:21] ═══════════════════════════════════════════════════════════
[2026-09-28 19:54:21] Modus: status
[2026-09-28 19:54:21] ═══════════════════════════════════════════════════════════
[2026-09-28 19:54:21] Status: Vergleiche Repo mit Home-Dir...
[2026-09-28 19:54:28] ═══════════════════════════════════════════════════════════
[2026-09-28 19:54:28] Modus: status
[2026-09-28 19:54:28] ═══════════════════════════════════════════════════════════
[2026-09-28 19:54:28] Status: Vergleiche Repo mit Home-Dir...
[2026-09-28 19:55:07] ═══════════════════════════════════════════════════════════
[2026-09-28 19:55:07] Modus: status
[2026-09-28 19:55:07] ═══════════════════════════════════════════════════════════
[2026-09-28 19:55:07] Status: Vergleiche Repo mit Home-Dir...
[WARN] ✗ nur im Repo: .bash_oc_smart.sh (nicht im Home)
[WARN] ✗ nur im Repo: .bash_oc_smart_aliases.sh (nicht im Home)
[WARN] ≠ geändert im Home: .zshrc
[OK] Status-Zusammenfassung:
[2026-09-28 19:55:07] ═══════════════════════════════════════════════════════════
[OK] Abgeschlossen
[2026-09-28 19:55:11] ═══════════════════════════════════════════════════════════
[2026-09-28 19:55:11] Modus: push
[2026-09-28 19:55:11] DRY-RUN: Keine Änderungen werden vorgenommen
[2026-09-28 19:55:11] ═══════════════════════════════════════════════════════════
[2026-09-28 19:55:11] Push: Synchronisiere Repo-Dateien ins Home-Dir...
[WARN] → update: .zshrc (Repo → Home) [lokale Änderung wird überschrieben]
[OK] Push abgeschlossen: 0 kopiert, 0 Backups, 0 ausgelassen
[2026-09-28 19:55:12] ═══════════════════════════════════════════════════════════
[OK] DRY-RUN abgeschlossen (keine Änderungen)
[2026-09-28 19:55:16] ═══════════════════════════════════════════════════════════
[2026-09-28 19:55:16] Modus: push
[2026-09-28 19:55:16] DRY-RUN: Keine Änderungen werden vorgenommen
[2026-09-28 19:55:16] ═══════════════════════════════════════════════════════════
[2026-09-28 19:55:16] Push: Synchronisiere Repo-Dateien ins Home-Dir...
[DEBUG] ⊙ unverändert: .bash_aliases
[DEBUG] ✚ neu: .bash_oc_smart.sh (Repo → Home)
[DEBUG] ✚ neu: .bash_oc_smart_aliases.sh (Repo → Home)
[DEBUG] ⊙ unverändert: .gitconfig
[DEBUG] ⊙ unverändert: .gitconfig-architeq
[DEBUG] ⊙ unverändert: .gitconfig-bc
[DEBUG] ⊙ unverändert: .gitconfig-nettworks
[DEBUG] ⊙ unverändert: .gitconfig-private
[DEBUG] ⊙ unverändert: .gitconfig-ti8m
[DEBUG] ⊙ unverändert: .gitignore_global
[DEBUG] ⊙ unverändert: .npmrc
[DEBUG] ⊙ unverändert: .p10k.zsh
[DEBUG] ⊙ unverändert: .profile
[DEBUG] ⊙ unverändert: .testcontainers.properties
[WARN] → update: .zshrc (Repo → Home) [lokale Änderung wird überschrieben]
[DEBUG] ⊙ unverändert: getsizes.sh
[OK] Push abgeschlossen: 0 kopiert, 0 Backups, 0 ausgelassen
[2026-09-28 19:55:16] ═══════════════════════════════════════════════════════════
[OK] DRY-RUN abgeschlossen (keine Änderungen)
[2026-09-28 19:55:22] ═══════════════════════════════════════════════════════════
[2026-09-28 19:55:22] Modus: push
[2026-09-28 19:55:22] ═══════════════════════════════════════════════════════════
[2026-09-28 19:55:22] Push: Synchronisiere Repo-Dateien ins Home-Dir...
[WARN] → update: .zshrc (Repo → Home) [lokale Änderung wird überschrieben]
[2026-09-28 19:55:22] Backup erstellt: .zshrc (vor Push) → /Users/u241100/mac-home/.sync-backups/.zshrc.20260928_195522.backup
[OK] Push abgeschlossen: 3 kopiert, 1 Backups, 0 ausgelassen
[2026-09-28 19:55:22] ═══════════════════════════════════════════════════════════
[OK] Abgeschlossen
[2026-09-28 19:55:27] ═══════════════════════════════════════════════════════════
[2026-09-28 19:55:27] Modus: status
[2026-09-28 19:55:27] ═══════════════════════════════════════════════════════════
[2026-09-28 19:55:27] Status: Vergleiche Repo mit Home-Dir...
[OK] Status-Zusammenfassung:
[2026-09-28 19:55:27] ═══════════════════════════════════════════════════════════
[OK] Abgeschlossen
[2026-09-28 19:57:29] ═══════════════════════════════════════════════════════════
[2026-09-28 19:57:29] Modus: status
[2026-09-28 19:57:29] ═══════════════════════════════════════════════════════════
[2026-09-28 19:57:29] Status: Vergleiche Repo mit Home-Dir...
[OK] Status-Zusammenfassung:
[2026-09-28 19:57:29] ═══════════════════════════════════════════════════════════
[OK] Abgeschlossen
+27 -15
View File
@@ -12,7 +12,8 @@
# - Mehrere Modi für verschiedene Szenarien
################################################################################
set -euo pipefail
# Note: Removed 'set -euo pipefail' as it breaks while-read loops with subshells
# We handle errors explicitly instead
# Farben
RED='\033[0;31m'
@@ -40,23 +41,30 @@ AUTO_BACKUP=true
################################################################################
log() {
echo -e "${BLUE}[$(date +'%Y-%m-%d %H:%M:%S')]${NC} $*" | tee -a "$LOG_FILE"
echo -e "${BLUE}[$(date +'%Y-%m-%d %H:%M:%S')]${NC} $*"
echo "[$(date +'%Y-%m-%d %H:%M:%S')] $*" >> "$LOG_FILE"
}
error() {
echo -e "${RED}[ERROR]${NC} $*" >&2 | tee -a "$LOG_FILE"
echo -e "${RED}[ERROR]${NC} $*" >&2
echo "[ERROR] $*" >> "$LOG_FILE"
}
success() {
echo -e "${GREEN}[OK]${NC} $*" | tee -a "$LOG_FILE"
echo -e "${GREEN}[OK]${NC} $*"
echo "[OK] $*" >> "$LOG_FILE"
}
warn() {
echo -e "${YELLOW}[WARN]${NC} $*" | tee -a "$LOG_FILE"
echo -e "${YELLOW}[WARN]${NC} $*"
echo "[WARN] $*" >> "$LOG_FILE"
}
verbose() {
[[ "$VERBOSE" == true ]] && echo -e "${BLUE}[DEBUG]${NC} $*" | tee -a "$LOG_FILE"
if [[ "$VERBOSE" == true ]]; then
echo -e "${BLUE}[DEBUG]${NC} $*"
echo "[DEBUG] $*" >> "$LOG_FILE"
fi
}
################################################################################
@@ -68,10 +76,10 @@ get_checksum() {
if [[ -f "$file" ]]; then
if command -v md5 &> /dev/null; then
# macOS
md5 -q "$file"
md5 -q "$file" 2>/dev/null
elif command -v md5sum &> /dev/null; then
# Linux
md5sum "$file" | awk '{print $1}'
md5sum "$file" 2>/dev/null | awk '{print $1}'
else
error "Weder md5 noch md5sum verfügbar"
return 1
@@ -141,22 +149,26 @@ mode_status() {
local identical=0
local modified=0
local repo_only=0
local repo_file
local basename_file
local home_file
local status
while IFS= read -r file; do
local repo_file="$REPO_DIR/$file"
local basename=$(basename "$file")
local home_file="$HOME_DIR/$basename"
repo_file="$REPO_DIR/$file"
basename_file=$(basename "$file")
home_file="$HOME_DIR/$basename_file"
check_file_status "$repo_file" "$home_file"
local status=$?
status=$?
case $status in
0)
verbose "✓ identisch: $basename"
verbose "✓ identisch: $basename_file"
((identical++))
;;
3)
warn "≠ geändert im Home: $basename"
warn "≠ geändert im Home: $basename_file"
if [[ "$VERBOSE" == true ]]; then
echo " Repo: $(get_checksum "$repo_file")"
echo " Home: $(get_checksum "$home_file")"
@@ -164,7 +176,7 @@ mode_status() {
((modified++))
;;
4)
warn "✗ nur im Repo: $basename (nicht im Home)"
warn "✗ nur im Repo: $basename_file (nicht im Home)"
((repo_only++))
;;
esac