Compare commits
2 Commits
98722536f1
...
6b47b8941c
| Author | SHA1 | Date | |
|---|---|---|---|
| 6b47b8941c | |||
| 9f401e48e9 |
@@ -44,9 +44,9 @@ darktable_common.sh → Gemeinsame Hilfsfunktionen (wird per source eingebund
|
|||||||
Dry-Run: `RSYNC_DRY_FLAG=(--dry-run)` wird zu allen Aufrufen hinzugefügt.
|
Dry-Run: `RSYNC_DRY_FLAG=(--dry-run)` wird zu allen Aufrufen hinzugefügt.
|
||||||
|
|
||||||
## itemize-changes Format
|
## itemize-changes Format
|
||||||
- `>f+++++++++` — neue Datei (Upload)
|
- `<f+++++++++` — neue Datei (Upload, an Remote gesendet)
|
||||||
- `<f+++++++++` — neue Datei (Download)
|
- `>f+++++++++` — neue Datei (Download, lokal empfangen)
|
||||||
- `>f` / `<f` ohne `+` — aktualisiert
|
- `<f` / `>f` ohne `+` — aktualisiert
|
||||||
- `*deleting` — gelöscht
|
- `*deleting` — gelöscht
|
||||||
|
|
||||||
## Sicherheitsmechanismen
|
## Sicherheitsmechanismen
|
||||||
|
|||||||
+38
-10
@@ -106,7 +106,7 @@ classify_filetype() {
|
|||||||
format_rsync_details() {
|
format_rsync_details() {
|
||||||
local log_file="$1" direction_label="$2" direction="$3"
|
local log_file="$1" direction_label="$2" direction="$3"
|
||||||
[ -f "$log_file" ] || return 0
|
[ -f "$log_file" ] || return 0
|
||||||
local prefix; [ "$direction" = "up" ] && prefix=">f" || prefix="<f"
|
local prefix; [ "$direction" = "up" ] && prefix="<f" || prefix=">f"
|
||||||
|
|
||||||
local label pattern files
|
local label pattern files
|
||||||
while IFS=: read -r label pattern; do
|
while IFS=: read -r label pattern; do
|
||||||
@@ -114,15 +114,43 @@ format_rsync_details() {
|
|||||||
| sed 's/^[^ ]* *//' | sort) || true
|
| sed 's/^[^ ]* *//' | sort) || true
|
||||||
[ -n "$files" ] || continue
|
[ -n "$files" ] || continue
|
||||||
|
|
||||||
local typ typed
|
declare -A dir_foto=() dir_xmp=() dir_sonstige=()
|
||||||
for typ in Foto XMP Datenbank Video Sonstiges; do
|
while IFS= read -r f; do
|
||||||
typed=$(echo "$files" | while IFS= read -r f; do
|
local fdir ftyp
|
||||||
[ "$(classify_filetype "$f")" = "$typ" ] && echo " $f"
|
fdir=$(dirname "$f")
|
||||||
done)
|
ftyp=$(classify_filetype "$f")
|
||||||
[ -n "$typed" ] || continue
|
case "$ftyp" in
|
||||||
log_step "$direction_label – $typ ($label)"
|
Foto) dir_foto["$fdir"]=$(( ${dir_foto["$fdir"]:-0} + 1 )) ;;
|
||||||
echo "$typed"
|
XMP) dir_xmp["$fdir"]=$(( ${dir_xmp["$fdir"]:-0} + 1 )) ;;
|
||||||
done
|
*) dir_sonstige["$fdir"]=$(( ${dir_sonstige["$fdir"]:-0} + 1 )) ;;
|
||||||
|
esac
|
||||||
|
done <<< "$files"
|
||||||
|
|
||||||
|
local dirs
|
||||||
|
dirs=$(printf '%s\n' "${!dir_foto[@]}" "${!dir_xmp[@]}" "${!dir_sonstige[@]}" \
|
||||||
|
| sort -u)
|
||||||
|
if [ -n "$dirs" ]; then
|
||||||
|
log_step "$direction_label ($label)"
|
||||||
|
while IFS= read -r fdir; do
|
||||||
|
local nf nx ns parts
|
||||||
|
nf=${dir_foto["$fdir"]:-0}
|
||||||
|
nx=${dir_xmp["$fdir"]:-0}
|
||||||
|
ns=${dir_sonstige["$fdir"]:-0}
|
||||||
|
parts=""
|
||||||
|
if [ "$nf" -gt 0 ]; then parts="${nf} Fotos"; fi
|
||||||
|
if [ "$nx" -gt 0 ]; then
|
||||||
|
if [ -n "$parts" ]; then parts="$parts, "; fi
|
||||||
|
parts="${parts}${nx} XMP"
|
||||||
|
fi
|
||||||
|
if [ "$ns" -gt 0 ]; then
|
||||||
|
if [ -n "$parts" ]; then parts="$parts, "; fi
|
||||||
|
parts="${parts}${ns} Sonstige"
|
||||||
|
fi
|
||||||
|
log " ${fdir}/ $parts"
|
||||||
|
done <<< "$dirs"
|
||||||
|
fi
|
||||||
|
|
||||||
|
unset dir_foto dir_xmp dir_sonstige
|
||||||
done <<EOF
|
done <<EOF
|
||||||
neu:^${prefix}[+]{9}
|
neu:^${prefix}[+]{9}
|
||||||
aktualisiert:^${prefix}[^+]
|
aktualisiert:^${prefix}[^+]
|
||||||
|
|||||||
+10
-10
@@ -35,8 +35,8 @@ done
|
|||||||
count_synced_files() {
|
count_synced_files() {
|
||||||
local log_file="$1" direction="$2" count=0
|
local log_file="$1" direction="$2" count=0
|
||||||
case "$direction" in
|
case "$direction" in
|
||||||
up) count=$(grep -cE '^>f|^cd' "$log_file" 2>/dev/null) || count=0 ;;
|
up) count=$(grep -cE '^<f|^cd' "$log_file" 2>/dev/null) || count=0 ;;
|
||||||
down) count=$(grep -cE '^<f|^cd' "$log_file" 2>/dev/null) || count=0 ;;
|
down) count=$(grep -cE '^>f|^cd' "$log_file" 2>/dev/null) || count=0 ;;
|
||||||
esac
|
esac
|
||||||
echo "$count"
|
echo "$count"
|
||||||
}
|
}
|
||||||
@@ -300,18 +300,18 @@ if [ "$DRY_RUN" = true ]; then
|
|||||||
upload_log=$(cat "$UPLOAD_LOG_DB" "$UPLOAD_LOG_PHOTOS" 2>/dev/null || true)
|
upload_log=$(cat "$UPLOAD_LOG_DB" "$UPLOAD_LOG_PHOTOS" 2>/dev/null || true)
|
||||||
download_log=$(cat "$DOWNLOAD_LOG_DB" "$DOWNLOAD_LOG_PHOTOS" 2>/dev/null || true)
|
download_log=$(cat "$DOWNLOAD_LOG_DB" "$DOWNLOAD_LOG_PHOTOS" 2>/dev/null || true)
|
||||||
|
|
||||||
UP_NEW=$( echo "$upload_log" | grep -cE '^>f[+]{9}' || echo 0)
|
UP_NEW=$( echo "$upload_log" | grep -cE '^<f[+]{9}' || true)
|
||||||
UP_UPD=$( echo "$upload_log" | grep -E '^>f' | grep -cvE '^>f[+]{9}' || echo 0)
|
UP_UPD=$( echo "$upload_log" | grep -E '^<f' | grep -cvE '^<f[+]{9}' || true)
|
||||||
UP_DEL=$( echo "$upload_log" | grep -cE '^\*deleting' || echo 0)
|
UP_DEL=$( echo "$upload_log" | grep -cE '^\*deleting' || true)
|
||||||
DN_NEW=$( echo "$download_log" | grep -cE '^<f[+]{9}' || echo 0)
|
DN_NEW=$( echo "$download_log" | grep -cE '^>f[+]{9}' || true)
|
||||||
DN_UPD=$( echo "$download_log" | grep -E '^<f' | grep -cvE '^<f[+]{9}' || echo 0)
|
DN_UPD=$( echo "$download_log" | grep -E '^>f' | grep -cvE '^>f[+]{9}' || true)
|
||||||
DN_DEL=$( echo "$download_log" | grep -cE '^\*deleting' || echo 0)
|
DN_DEL=$( echo "$download_log" | grep -cE '^\*deleting' || true)
|
||||||
|
|
||||||
log_step "Trockenlauf-Ergebnis"
|
log_step "Trockenlauf-Ergebnis"
|
||||||
log " Upload: $UP_NEW neu | $UP_UPD aktualisiert | $UP_DEL gelöscht (Server)"
|
log " Upload: $UP_NEW neu | $UP_UPD aktualisiert | $UP_DEL gelöscht"
|
||||||
log " Download: $DN_NEW neu | $DN_UPD aktualisiert | $DN_DEL gelöscht → Backup: $BACKUP_PHOTO_DIR"
|
log " Download: $DN_NEW neu | $DN_UPD aktualisiert | $DN_DEL gelöscht → Backup: $BACKUP_PHOTO_DIR"
|
||||||
|
|
||||||
if [ "$((TOTAL_SENT + TOTAL_RECEIVED))" -gt 0 ]; then
|
if [ "$((UP_NEW + UP_UPD + UP_DEL + DN_NEW + DN_UPD + DN_DEL))" -gt 0 ]; then
|
||||||
if ask_user "Details" "Details der zu übertragenden Dateien anzeigen?"; then
|
if ask_user "Details" "Details der zu übertragenden Dateien anzeigen?"; then
|
||||||
format_rsync_details "$UPLOAD_LOG_DB" "Upload" "up"
|
format_rsync_details "$UPLOAD_LOG_DB" "Upload" "up"
|
||||||
format_rsync_details "$UPLOAD_LOG_PHOTOS" "Upload" "up"
|
format_rsync_details "$UPLOAD_LOG_PHOTOS" "Upload" "up"
|
||||||
|
|||||||
Reference in New Issue
Block a user