Some clients asked us if you can set up only database backups in WHM. For some, this will sound strange, but there are users who want such a feature.
You can access WHM backup settings via WHM->Backup->Backup Configuration. Unfortunately, there is no option at this moment to backup only users’ databases.
Update: As of April 20, 2020, this cPanel request is in “Open Discussion” status. You can comment and vote at cPanel Feature Requests Site
What solutions do you have? You can use bash commands. One command to backup all the databases on the server to a .gz archive is:
root@www [/backup]# mysqldump --all-databases | gzip > /backup/$(date +%Y-%h-%d)-alldatabases.sql.gz
This will create a backup with all MySQL/MariaDB databases on the server. The filename will include the current date. (e.g. 2018-Sep-25-alldatabases.sql.gz) You can modify the command per your needs. You can also create a cron job to run it at specific times.
Another possibility is to backup each database on the server individually. For this create a new file like backupdbs.sh The content of the file is:
#!/bin/bash mysql=/usr/bin/mysql mysqldump=/usr/bin/mysqldump date=$(date +%Y-%h-%d) backupdir="/backup" mkdir -p $backupdir/$date databases=`$mysql -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema)"` for db in $databases; do echo $db $mysqldump --opt --databases $db | gzip > "$backupdir/$date/$db.sql.gz" done
To run the script:
root@www [/backup]# perl backupdbs.sh
As in the previous case, you can also adjust the script per your needs and create a cron job.