viewtopic.php?f=32&t=23815 that faithfully worked for 10 years,
and numerous upgrades finally stopped working (and yes, the Backup saved me a couple times in the most recent years).
The backups produce a file with nothing in it, and it looks like my error is that it wants a root password, and I tried putting it in my script but it didn't work. "Got error: 1045: "Access denied for user 'root'@'localhost' (using password: NO)" when trying to connect" Mysql backup script completed successfully!
I checked my auth.log
Code: Select all
May 27 15:23:00 CCTV sshd[93016]: Accepted publickey for dazed from 192.168.69.18 port 54929 ssh2: RSA SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxx
Code: Select all
May 27 15:23:01 CCTV mariadbd[863]: 2025-05-27 15:23:01 2793 [Warning] Access denied for user 'user'@'localhost' (using password: YES)
MySql database
Code: Select all
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| zm |
+--------------------+
5 rows in set (0.001 sec)
Code: Select all
#!/bin/bash
# Path to the tools this scripts needs
MYSQLDUMP="/usr/bin/mysqldump"
GZIP="/bin/gzip"
FIND="/usr/bin/find"
# Check to see if this script has access to all the commands it needs
for CMD in $MYSQLDUMP $GZIP $FIND; do
type $CMD &> /dev/null
if [ $? -ne 0 ]; then
echo
echo "ERROR: The script cannot find the required command \"${CMD}\"."
echo
exit 1
fi
done
# Enter SQL database login credentials
USER="root"
PASS="mypass"
# Specify which databases to backup
DB="--all-databases"
# Specify where the databases will be saved to
BKUP_PATH="/path/to/your/backup/folder"
# Format for the timestamp
timestamp="$(date +%Y-%m-%d_%a)"
# Run the backup and compress it
error=0
${MYSQLDUMP} -u${USER} -p${PASS} --events --single-transaction --quick ${DB} | ${GZIP} -9 > ${BKUP_PATH}/Nightly_dB_Backup_${timestamp}.sql.gz
if [ "$?" -ne 0 ]; then
echo
echo "WARNING: Mysqldump returned an error!"
echo
error=1
fi
# Now find & delete old backups we no longer need
${FIND} ${BKUP_PATH} -maxdepth 1 -type f -mtime +30 -delete
if [ "$?" -ne 0 ]; then
echo
echo "WARNING: Find returned an error!"
echo
error=1
fi
if [ "$error" -eq 0 ]; then
echo "Mysql backup script completed successfully!"
fi