#!/bin/bash
exec >> /4server/data/log/backupContainer.log 2>&1
echo "$(date '+%Y-%m-%d %H:%M') Backup container $1"

source /4server/sbin/helpers

BIN_PATH="/4server/sbin"

UUID="$1"

if [[ -z "$UUID" ]]; then
    echo "Usage: $0 <uuid>"
    exit 1
fi

get_contract_info

# Extract the second part of UUID (split by "-")
SECOND_PART=$(echo "$UUID" | cut -d'-' -f2)

echo "Conatiner Type $UUID"

# Decide which script to run
case "$SECOND_PART" in
   001)
        "$BIN_PATH/backup/N8N"
        ;;
   002)
        "$BIN_PATH/backup/ODOO"
        ;;
   003)
        "$BIN_PATH/backup/ODOO"
        ;;
   004)
        "$BIN_PATH/backup/ODOO"
        ;;

  *)
        echo "Unknown UUID type: $SECOND_PART"
        exit 2
        ;;
esac
