October 19

How to terminate an active transfer when the transfer process no longer exists

Symptoms
Transfers hang indefinitely or cannot be terminated.

Description
A transfer will still have an active session if the transfer process is terminated outside of the “Review Transfers and Restores” interface, such as when the server is rebooted while a transfer is running. This is because the transfer session’s state is stored in an SQLite database, and is not associated with a specific PID.

Workaround
Please note that this workaround should only be implemented if the transfer (rsync) process no longer exists.

1. Access the server’s command line as the ‘root’ user via SSH or “Terminal” in WHM.
2. Run the following command to Identify the unfinished transfer’s session ID.
/usr/local/cpanel/3rdparty/bin/sqlite3 /var/cpanel/transfer_sessions/whmxfer.sqlite "select sessionid from sessions where state != '100'"

3. Run the following command to change the session ID to the completed state.

/usr/local/cpanel/3rdparty/bin/sqlite3 /var/cpanel/transfer_sessions/whmxfer.sqlite "update sessions set state='200', endtime=date('now') where sessionid='$sessionID'"

Please note that “$sessionID” must be replaced with the session ID found from the previous command.

It is copy of the guide written by Daniel Pearsall that is stored here

September 26

how to make a bulk nameservers update in cPanel

Bulk Nameservers update in cPanel:

Step 1, do backup:

cp -rf /var/named{,.backup}

Step 2, update NS:

oldns="ns1.old.domain"; newns="ns1.new.domain" ; find /var/named/*.db -exec perl -pi -e "s/(?<=IN\s\NS\s)$oldns/$newns/g" '{}' \;
oldns="ns2.old.domain"; newns="ns2.new.domain" ; find /var/named/*.db -exec perl -pi -e "s/(?<=IN\s\NS\s)$oldns/$newns/g" '{}' \;

Step 3, new serial records:

find /var/named/*.db -mtime -1 -exec perl -pi -e 'if (/^\s+(\d{10})\s+;\s?(?i)serial/i) { my $i = $1+1; s/$1/$i/;}' '{}' \;

Step 4, restart DNS service:

/scripts/restartsrv_named

Original post is here

July 10

Mdadm RAID array creation from the command line:

Check the disks present on the server:

lsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINT

Example:

NAME SIZE FSTYPE TYPE MOUNTPOINT
sda 5.5T disk
sdb 5.5T disk
sdc 5.5T disk
sdd 5.5T disk
nvme0n1 477G disk
├─nvme0n1p1 511M vfat part /boot/efi
├─nvme0n1p2 476G ext4 part /
├─nvme0n1p3 512M swap part [SWAP]
└─nvme0n1p4 2M iso9660 part

Creating RAID 5 array (we will use it to store the backups):
Continue reading