get-logs.sh 596 B

1234567891011121314151617181920212223
  1. #!/bin/bash
  2. # Source and destination directories
  3. SRC_DIR="/var/lib/pgsql/15/data/log/"
  4. DEST_DIR="/usr/share/nginx/html/paad/pgsql-log/"
  5. # Days of the week
  6. DAYS=("Mon" "Tue" "Wed" "Thu" "Fri" "Sat" "Sun")
  7. echo "Done"
  8. # Iterate over each day and copy the file if it exists
  9. for day in "${DAYS[@]}"; do
  10. src_file="${SRC_DIR}postgresql-${day}.log"
  11. dest_file="${DEST_DIR}postgresql-${day}.log"
  12. if [[ -f "$src_file" ]]; then
  13. sudo cp "$src_file" "$dest_file"
  14. echo "Copied ${src_file} to ${dest_file}"
  15. else
  16. echo "File ${src_file} not found"
  17. fi
  18. done