Posts Tagged ‘Hosting’
January 26th, 2013
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
08 | $source_server_ip = "your_domain_or_IP" ; |
09 | $cpanel_account = "userid" ; |
10 | $cpanel_password = "password" ; |
12 | $ftphost = "ip_or_hostname_of_ftp" ; |
16 | $email_notify = 'your_email@domain.com' ; |
17 | $backupexpireindays =21; |
22 | $backupexpireindays =( $backupexpireindays *24)*3600; |
24 | $xmlapi = new xmlapi( $source_server_ip ); |
25 | $xmlapi --->password_auth( $cpanel_account , $cpanel_password ); |
26 | $xmlapi ->set_port( '2083' ); |
29 | $conn_id = ftp_connect( $ftphost ); |
30 | $login_result = ftp_login( $conn_id , $ftpacct , $ftppass ); |
32 | ftp_chdir( $conn_id , $logs_dir ); |
33 | $files = ftp_nlist( $conn_id , "." ); |
34 | foreach ( $files as $filename ) { |
35 | $fileCreationTime = ftp_mdtm( $conn_id , $filename ); |
39 | $fileAge = $fileAge - $fileCreationTime ; |
40 | if ( $fileAge > $backupexpireindays ) { |
42 | ftp_delete( $conn_id , $filename ); |
59 | $xmlapi ->set_output( 'json' ); |
60 | 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
January 26th, 2013
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
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.
(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!
January 24th, 2013
Yet another infographic. Well, Infographics are much better way to grasp the information, especially if they’re well made. This cool infographic from Tech King lists out some of the most important events in the history of Domain Names.
Pakistan ranks 55th with only 46 thousand domain names in Top countries for domain registration.
Read the rest of this entry »