added modules

This commit is contained in:
oliver
2026-04-21 11:51:35 -03:00
parent e672b1d2c6
commit 717045baa6
+21
View File
@@ -54,3 +54,24 @@ while IFS= read -r old_file; do
done < <(ls -t "$BACKUP_DIR"/[0-9]*.zip 2>/dev/null | tail -n +$((BACKUP_SLOTS + 1))) done < <(ls -t "$BACKUP_DIR"/[0-9]*.zip 2>/dev/null | tail -n +$((BACKUP_SLOTS + 1)))
log "Backup finished successfully." log "Backup finished successfully."
# --- Custom modules snapshot ---
# Archive /4server/data/$UUID/git-server/repos/local/custom/ into .current.tar.gz.
# Rebuilt only when at least one file inside is newer than the existing archive,
# so borg backup dedup sees an identical blob on unchanged runs.
CUSTOM_SRC="/4server/data/$UUID/git-server/repos/local/custom"
CUSTOM_ARCHIVE="$BACKUP_DIR/.current.tar.gz"
if [ ! -d "$CUSTOM_SRC" ]; then
log "Custom modules directory not found, skipping: $CUSTOM_SRC"
elif [ ! -f "$CUSTOM_ARCHIVE" ] || \
doas find "$CUSTOM_SRC" -newer "$CUSTOM_ARCHIVE" -print -quit | grep -q .; then
log "Changes detected in custom modules — rebuilding .current.tar.gz"
# Write to a temp file first; mv is atomic, so borg never sees a partial archive
doas tar -czf "${CUSTOM_ARCHIVE}.tmp" \
-C "/4server/data/$UUID/git-server/repos/local" custom
doas mv "${CUSTOM_ARCHIVE}.tmp" "$CUSTOM_ARCHIVE"
log ".current.tar.gz updated: $(doas du -sh "$CUSTOM_ARCHIVE" | cut -f1)"
else
log "No changes in custom modules — .current.tar.gz is up to date"
fi