Plesk backups fail with errors like:
mariadb-dump: Got error: 2002: "Can't connect to server on 'localhost' (111)"
unknown variable 'defaults-file=/etc/my.cnf'
or similar1045: Access denied for user 'admin'@'localhost'
This happens because Plesk tries to connect to MariaDB using TCP (--host=localhost --port=3306
) and a configuration file (--defaults-file=/etc/my.cnf
) that conflicts with MariaDB’s socket-only mode (skip-networking
).
Environment: AlmaLinux 8, MariaDB 10.11.12, Plesk 18.0.69.
Ensure you have:
/etc/psa/.psa.shadow
with the admin
password.Save the original mariadb-dump
binary.
mv /usr/bin/mariadb-dump /usr/bin/mariadb-dump.orig
Create a wrapper for mariadb-dump
to use socket connections.
cat << 'EOF' > /usr/bin/mariadb-dump
#!/bin/bash
args=()
skip_next=false
for arg in "$@"; do
if [ "$skip_next" = true ]; then
skip_next=false
continue
fi
if [[ "$arg" == "--defaults-file=/etc/my.cnf" || "$arg" == "--host=localhost" || "$arg" == "--port=3306" ]]; then
skip_next=true
continue
fi
if [[ "$arg" == --host=* || "$arg" == --port=* ]]; then
continue
fi
args+=("$arg")
done
/usr/bin/mariadb-dump.orig --socket=/var/lib/mysql/mysql.sock --user=admin --password="$(cat /etc/psa/.psa.shadow)" "${args[@]}"
EOF
chmod 755 /usr/bin/mariadb-dump
Run a test backup, replacing example.com
with your domain.
/usr/local/psa/bin/pleskbackup --domains-name example.com -v
Expected: Backup completes with status="success"
.
Save the wrapper to restore after MariaDB updates.
cp /usr/bin/mariadb-dump /root/mariadb-dump-wrapper.sh
Add to system notes:
/usr/bin/mariadb-dump
fixes Plesk backups./root/mariadb-dump-wrapper.sh
.After MariaDB updates, check:
head -n 1 /usr/bin/mariadb-dump
If not #!/bin/bash
, restore:
mv /usr/bin/mariadb-dump /usr/bin/mariadb-dump.bak
cp /root/mariadb-dump-wrapper.sh /usr/bin/mariadb-dump
chmod 755 /usr/bin/mariadb-dump
If the backup fails, contact Plesk support.