#!/bin/bash

# Database credentials
DB_HOST="localhost"
DB_USER="serveri1_jumpravaspamatskola"
DB_PASSWORD="dLVQ])rqINUy"
DB_NAME="serveri1_jumpravaspamatskola"

# Output file name (e.g., jumpravaspamatskola_2024-08-19.sql)
OUTPUT_FILE="/home/serveri1/${DB_NAME}_$(date +'%Y-%m-%d').sql"

# Dump the database
mysqldump --host=$DB_HOST --user=$DB_USER --password=$DB_PASSWORD $DB_NAME > $OUTPUT_FILE

# Check if the dump was successful
if [ $? -eq 0 ]; then
  echo "Database dump completed successfully: $OUTPUT_FILE"
else
  echo "Database dump failed!"
  exit 1
fi
