Update ODOO_19

This commit is contained in:
oliver
2026-04-21 12:02:39 -03:00
parent 717045baa6
commit 902c43ec89
+10 -7
View File
@@ -19,9 +19,11 @@ log "DB host: $POSTGRES_HOST"
# Build paths # Build paths
FILENAME="$(date +"%Y%m%d_%H%M").zip" FILENAME="$(date +"%Y%m%d_%H%M").zip"
BACKUP_DIR="/BACKUP/$UUID" BACKUP_DIR="/BACKUP/$UUID"
BB_DIR="$BACKUP_DIR/bb"
# Ensure backup directory exists (requires elevated permissions like other ops) # Ensure backup directories exist (requires elevated permissions like other ops)
doas mkdir -p "$BACKUP_DIR" doas mkdir -p "$BACKUP_DIR"
doas mkdir -p "$BB_DIR"
# Perform database dump inside the container # Perform database dump inside the container
log "Starting dump -> $BACKUP_DIR/$FILENAME" log "Starting dump -> $BACKUP_DIR/$FILENAME"
@@ -40,10 +42,11 @@ doas chmod 600 "$BACKUP_DIR"/[0-9]*.zip
# Hand ownership back to odoo inside the container # Hand ownership back to odoo inside the container
doas docker exec "$UUID" chown odoo:odoo -R /mnt/backup doas docker exec "$UUID" chown odoo:odoo -R /mnt/backup
# Update the current.zip symlink to point at the backup just created # Update the current.zip symlink inside bb/ pointing at the backup just created.
# ln -sf uses a relative target so the symlink stays valid if the dir is moved # Target is relative (../$FILENAME) because the symlink lives one level deeper
doas ln -sf "$FILENAME" "$BACKUP_DIR/current.zip" # than the actual .zip files, so it stays valid if the directory is moved.
log "current.zip -> $FILENAME" doas ln -sf "../$FILENAME" "$BB_DIR/current.zip"
log "bb/current.zip -> ../$FILENAME"
# Remove old backups beyond the configured slot count # Remove old backups beyond the configured slot count
# Process substitution (< <(...)) keeps the loop in the main shell so # Process substitution (< <(...)) keeps the loop in the main shell so
@@ -60,13 +63,13 @@ log "Backup finished successfully."
# Rebuilt only when at least one file inside is newer than the existing archive, # 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. # so borg backup dedup sees an identical blob on unchanged runs.
CUSTOM_SRC="/4server/data/$UUID/git-server/repos/local/custom" CUSTOM_SRC="/4server/data/$UUID/git-server/repos/local/custom"
CUSTOM_ARCHIVE="$BACKUP_DIR/.current.tar.gz" CUSTOM_ARCHIVE="$BB_DIR/current_modules.tar.gz"
if [ ! -d "$CUSTOM_SRC" ]; then if [ ! -d "$CUSTOM_SRC" ]; then
log "Custom modules directory not found, skipping: $CUSTOM_SRC" log "Custom modules directory not found, skipping: $CUSTOM_SRC"
elif [ ! -f "$CUSTOM_ARCHIVE" ] || \ elif [ ! -f "$CUSTOM_ARCHIVE" ] || \
doas find "$CUSTOM_SRC" -newer "$CUSTOM_ARCHIVE" -print -quit | grep -q .; then doas find "$CUSTOM_SRC" -newer "$CUSTOM_ARCHIVE" -print -quit | grep -q .; then
log "Changes detected in custom modules — rebuilding .current.tar.gz" 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 # Write to a temp file first; mv is atomic, so borg never sees a partial archive
doas tar -czf "${CUSTOM_ARCHIVE}.tmp" \ doas tar -czf "${CUSTOM_ARCHIVE}.tmp" \
-C "/4server/data/$UUID/git-server/repos/local" custom -C "/4server/data/$UUID/git-server/repos/local" custom