#!/bin/bash

# Configuration
USER="pixiegro"
DB_USER="pixiegro"
DB_PASS="Marsveliu@22"
BACKUP_DIR="/home/$USER/public_html/db"

mkdir -p $BACKUP_DIR
DATE=$(date +%F_%H-%M-%S)

# Get the list of databases into a single line space-separated string
DBS=$(mysql -u "$DB_USER" -p"$DB_PASS" -Bse "SHOW DATABASES;" | grep -Ev "(Database|information_schema|performance_schema|sys)")

for db in $DBS; do
    mysqldump -u "$DB_USER" -p"$DB_PASS" --single-transaction "$db" | gzip > "$BACKUP_DIR/${db}_$DATE.sql.gz"
done
