Posts Tagged ‘WHM’

Poblem In Cpanel with VPS, Disk Quota Doesnt working

No Comments »

If you are using CPanel with VPS and getting Quota errors.
OK here is the solution for VPS.
Please try following:

1- First change the /etc/fstab file similar to as follows:

# This file is edited by fstab-sync - see 'man fstab-sync' for details
LABEL=/ / ext3,usrquota defaults 1
LABEL=/boot /boot ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmps defaults 0 0
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
LABEL=SWAP-sda2 swap swap defaults 0 0

2- change in the

/etc/sysconfig/vz-scripts/xxx.conf
setup it to QUOTAUGIDLIMIT="3000"
reboot

3- this command as well as in sequence :

quotaoff -av
quotaon -av
/scripts/fixquotas

it should solve the issue


CPanel full backup (all files+databases+emails) PHP script

23 Comments »

 

I was looking for a working script to take full backup (all files+databases+emails) manually or using cron services on my hosting server, each CPanel user by one. But most of the scripts are either old, totally unusable or commercial.
So I wrote one for my own use and sharing here so others don’t need to re-invent the wheel

password_auth($cpanel_account,$cpanel_password);
$xmlapi->set_port('2083');
 
// Delete any other backup with filetime greater than expire time, before create new backup
$conn_id = ftp_connect($ftphost);
$login_result = ftp_login($conn_id, $ftpacct, $ftppass);

ftp_chdir($conn_id, $logs_dir);
$files = ftp_nlist($conn_id, ".");
foreach ($files as $filename) {
        $fileCreationTime = ftp_mdtm($conn_id, $filename);
        //$date = date("F j, Y, g:i a", ftp_mdtm($conn_id, $filename));
        //print "
Timestamp of '$filename': $date"; $fileAge=time(); $fileAge=$fileAge-$fileCreationTime; if ($fileAge > $backupexpireindays) { // Is the file older than the given time span? //echo "
The file $filename is older than Expire time :$expiretime ...Deleting\n"; ftp_delete($conn_id, $filename); //echo "
Deleted

"; } } ftp_close($conn_id); $api_args = array( 'passiveftp', $ftphost, $ftpacct, $ftppass, $email_notify, 21, '/' ); $xmlapi->set_output('json'); print $xmlapi->api1_query($cpanel_account,'Fileman','fullbackup',$api_args); ?>

You need to save it with .php extension (upload it to your server) and download include file from xmlapi.zip(right click->save as) and extract it to the same folder (on your web server). Create cron job from your CPanel or trigger it manually to get full backup in your FTP server, That’s it.
OR
You can fork from my git hub Repositories at cpanel-Fullbackup
Enjoy


Using CPanel/WHM API to get detail list of all accounts on server

No Comments »

 

Today I had this need to get a list of WHM Accounts using one of its APIs. I have never used it before but it was really simple to use. It returns an xml file that you can manipulate using your prefered language and store it in database for reporting etc.

Here is what you need to do, connect to your server using SSH and run the following command

wget http://your-server-ip:2086/xml-api/listaccts --http-user=myuser --http-password=mypass --output-document=listaccts.xml

Replace your-server-ip with your WHM’s ip and myuser/mypass with the actual WHM/CPanel password. The resultant xml file will be saved as “listaccts.xml” in the same directory as you ran the command in.

If you feel a bit insecure running these command over SSH or don’t have shell access to the server then visit this page on your browser and save it as an xml file.

http://your-server-ip:2086/xml-api/listaccts

(again, substitute your-server-ip with the actual WHM ip address, substitute HTTP with HTTPS and port to 2087 for HTTPS if enabled on your server / FQDN)

Enjoy!