#!/bin/bash

# Source and destination directories
SRC_DIR="/var/lib/pgsql/15/data/log/"
DEST_DIR="/usr/share/nginx/html/paad/pgsql-log/"

# Days of the week
DAYS=("Mon" "Tue" "Wed" "Thu" "Fri" "Sat" "Sun")

echo "Done"
# Iterate over each day and copy the file if it exists
for day in "${DAYS[@]}"; do
    src_file="${SRC_DIR}postgresql-${day}.log"
    dest_file="${DEST_DIR}postgresql-${day}.log"
    
    if [[ -f "$src_file" ]]; then
        sudo cp "$src_file" "$dest_file"
        echo "Copied ${src_file} to ${dest_file}"
    else
        echo "File ${src_file} not found"
    fi
    
done
