Select Page

webalizer analog awstats cleanup script on cPanel/WHM

i usually disable awstats analog and webalizer on cPanel/WHM because there’s much better alternatives out there, like Google Analytics, however if you’re doing it on a server that has been running them for a while now, the cached data remains, so here’s a script to clean that up:

#!/bin/bash -x
for i in $(ls /var/cpanel/users)
do
cd /home/${i}/tmp && rm -rf analog awstats webalizer
done

cPanel/WHM clear user logs script

Sometimes on cPanel/WHM the php user logs get large and/or might not get rotated properly. This script should take care of this

nano /root/logs.clear.sh

paste the contents below

chmod 700 logs.clear.sh

./root/logs.clear.sh

#!/bin/bash -x
for i in $(ls /var/cpanel/users)
do
cd /home/${i}/logs && find . -type f -name “*.php.error.log” -print0 | xargs -0 -I{} sh -c ‘echo “” > “{}”‘\;
done

Caught Error Cpanel::Exception::Backup::CorruptedBackupData

Caught Error Cpanel::Exception::Backup::CorruptedBackupData : Ran some backups manually and stumbled into this error while checking the logs to see if the backups work fine (always check your logs, boys)

Caught Error Cpanel::Exception::Backup::CorruptedBackupData

The system was unable to interpret backup data. Error: “Can’t call method “quote” on an undefined value at /usr/local/cpanel/Cpanel/Backup/Metadata.pm line 1704.
”.
at /usr/local/cpanel/Cpanel/Backup/Metadata.pm line 926.
Cpanel::Backup::Metadata::__ANON__(__CPANEL_HIDDEN__…) called at /usr/local/cpanel/3rdparty/perl/536/cpanel-lib/Try/Tiny.pm line 121
Try::Tiny::try(CODE(0x22e56c0), Try::Tiny::Catch=REF(0x22a6998)) called at /usr/local/cpanel/Cpanel/Backup/Metadata.pm line 928

As it seems, this happens if you are running your backup volumes on a CIFS mount that is missing the “,user_xattr” parameter.

So what you need to do, is readjust your /etc/fstab as follows:

old:

//user.your-storagebox.de/backup /mnt/backups cifs iocharset=utf8,rw,credentials=/etc/backup-credentials.txt,uid=root,gid=root,file_mode=0660,dir_mode=0770 0 0

new:

//user.your-storagebox.de/backup /mnt/backups cifs iocharset=utf8,rw,credentials=/etc/backup-credentials.txt,uid=root,gid=root,file_mode=0660,dir_mode=0770,user_xattr 0 0

Then run “mount -o remount /mnt/backups” and in order to test is everything is working fine, do a “lsattr /mnt/backups” which should output the attributes of the mount. If it errors out, it means the mount doesn’t support extended attributes.

That should take care of things,

Cheers!

Switch from MySQL 8 to MariaDB on cPanel/WHM

Apparently, the newest setup of cPanel servers comes in with MySQL8 by default. i have tried migrating a customer but there are some database incompatibilities, therefore we just put up another box with AlmaLinux 8 and here are the steps for performing a MySQL swap to MariaDB:

Now, this works on brand new servers, where maybe you forgot to setup MariaDB right in the beginning as per the cPanel tutorial here. If you have databases/users on the server and you still wish to downgrade, make sure to back them up beforehand, as we’re removing the SQL Server and the data.

  • Disable MySQL monitor in WHM >> Service Manager (we don’t want MySQL attempts to restart the service while we are working)
  • i cannot live without this: dnf install bash-completion
  • Stop MySQL: systemctl stop mysqld
  • mv /var/lib/mysql /var/lib/mysql-old
  • mv /etc/my.cnf /etc/my.cnf-old
  • Remove the MySQL rpm’s: yum remove mysql-community-client-8.0.32-1.el8.x86_64 mysql-community-common-8.0.32-1.el8.x86_64 mysql-community-libs-8.0.32-1.el8.x86_64 mysql-community-server-8.0.32-1.el8.x86_64 mysql-community-icu-data-files-8.0.32-1.el8.x86_64 mysql80-community-release-el8-4.noarch mysql-community-client-plugins-8.0.32-1.el8.x86_64
  • Add the MariaDB repo. i am adding the 10.3 – feel free to change for whatever version you need.
  • cat >> /etc/yum.repos.d/mariadb.repo << EOF
    [mariadb]
    name = MariaDB
    baseurl = http://yum.mariadb.org/10.3/rhel8-amd64
    module_hotfixes=1
    gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
    gpgcheck=1
    EOF
  • Install the MariaDB Server and Client: dnf update && dnf install MariaDB-client.x86_64 MariaDB-common.x86_64 MariaDB-server.x86_64
  • WHM >> SQL Services >> MySQL Root Password – > Change the MySQL root password
  • Force cPanel/WHM upgrade: /scripts/upcp –force
  • Enable the new MariaDB installation: systemctl enable mariadb.service
  • Enable the MySQL monitor in WHM >> Service Manager

That’s it! Enjoy!

Pin It on Pinterest