Advertisement
antun3s

cPanel - Backup Full

Jun 29th, 2016
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.72 KB | None | 0 0
  1. <?php
  2. // PHP script to allow periodic cPanel backups automatically, optionally to a remote FTP server.
  3. // This script contains passwords. It is important to keep access to this file secure (we would ask you to place it in your home directory, not public_html)
  4. // You need create 'backups' folder in your home directory ( or any other folder that you would like to store your backups in ).
  5. // ********* THE FOLLOWING ITEMS NEED TO BE CONFIGURED *********
  6. // Information required for cPanel access
  7. $cpuser = "usuariocpanel"; // Username used to login to cPanel
  8. $cppass = 'senhacpaneç'; // Password used to login to cPanel. NB! you could face some issues with the "$#&/" chars in the password, so if script does not work, please try to change the password.
  9. $domain = "dominio.com.br";// Your main domain name
  10. $skin = "x3"; // Set to cPanel skin you use (script will not work if it does not match). Most people run the default "x" theme or "x3" theme
  11. // Information required for FTP host
  12. $ftpuser = "usuarioftp"; // Username for FTP account
  13. $ftppass = 'senhaftp'; // Password for FTP account NB! you could face some issues with the "$#&/" chars in the password, so if script does not work, please try to change the password.
  14. $ftphost = "servidorFTP"; // IP address of your hosting account
  15. $ftpmode = "passiveftp"; // FTP mode
  16. // Notification information
  17. $notifyemail = "email@dominio.com.br"; // Email address to send results
  18. // Secure or non-secure mode $secure = 0; // Set to 1 for SSL (requires SSL support), otherwise will use standard HTTP
  19. // Set to 1 to have web page result appear in your cron log $debug = 0;
  20. // *********** NO CONFIGURATION ITEMS BELOW THIS LINE *********
  21. $ftpport = "21";
  22. $ftpdir = "/"; // Directory where backups stored (make it in your /home/ directory). Or you can change 'backups' to the name of any other folder created for the backups;
  23. if ($secure) {
  24. $url = "ssl://".$domain;
  25. $port = 2083;
  26. } else {
  27. $url = $domain;
  28. $port = 2082;
  29. }
  30. $socket = fsockopen($url,$port);
  31. if (!$socket) { echo "Failed to open socket connection... Bailing out!n"; exit; }
  32. // Encode authentication string
  33. $authstr = $cpuser.":".$cppass;
  34. $pass = base64_encode($authstr);
  35. $params = "dest=$ftpmode&email=$notifyemail&server=$ftphost&user=$ftpuser&pass=$ftppass&port=$ftpport&rdir=$ftpdir&submit=Generate Backup";
  36. // Make POST to cPanel
  37. fputs($socket,"POST /frontend/".$skin."/backup/dofullbackup.html?".$params." HTTP/1.0\r\n");
  38. fputs($socket,"Host: $domain\r\n");
  39. fputs($socket,"Authorization: Basic $pass\r\n");
  40. fputs($socket,"Connection: Close\r\n");
  41. fputs($socket,"\r\n");
  42. // Grab response even if we do not do anything with it.
  43. while (!feof($socket)) {
  44. $response = fgets($socket,4096); if ($debug) echo $response;
  45. }
  46. fclose($socket);
  47. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement