#!/bin/bash
# Optional variables for a backup script

BACKUP_QUERY="use mysql; SELECT name FROM data_backup_for_script where active='1' order by id"

DB_NAME=$1  # First argument passed from PHP
MYSQL_USER="root"
MYSQL_PASS="_k.Z3JIQDzDV"
BACKUP_DIR="client-nirdosh/$(date +%Y-%m-%d_%H)"
mkdir -p "$BACKUP_DIR"

if [ -z "$DB_NAME" ]; then
    echo "No database name provided."
    exit 1
fi

mysqldump -u "$MYSQL_USER" -p"$MYSQL_PASS" "$DB_NAME" | gzip > "$BACKUP_DIR/$DB_NAME.sql.gz"
#echo "Backup complete for database: $DB_NAME"
#chown -R rise2:rise2 database_backup